fix(region): prohibit resizing the disk of a esxi vm with instance snapshots

This commit is contained in:
rainzm
2021-08-05 18:59:35 +08:00
parent 55e1bb709f
commit e01cdbb27d
+9
View File
@@ -862,6 +862,15 @@ func (disk *SDisk) PerformResize(ctx context.Context, userCred mcclient.TokenCre
if guest != nil {
return nil, httperrors.NewUnsupportOperationError("try use /servers/<%s>/resize-disk API", guest.Id)
}
if guest.Hypervisor == api.HYPERVISOR_ESXI {
c, err := guest.GetInstanceSnapshotCount()
if err != nil {
return nil, errors.Wrapf(err, "unable to GetInstanceSnapshotCount for guest %s", guest.GetName())
}
if c > 0 {
return nil, httperrors.NewUnsupportOperationError("the disk of a esxi virtual machine with instance snapshots does not support resizing")
}
}
sizeMb, err := input.SizeMb()
if err != nil {
return nil, err