Merge pull request #12004 from rainzm/automated-cherry-pick-of-#12003-upstream-release-3.8

Automated cherry pick of #12003: fix(region): check instancesnapshot in correct place when resize disk
This commit is contained in:
Zexi Li
2021-08-26 10:42:38 +08:00
committed by GitHub
2 changed files with 9 additions and 9 deletions
-9
View File
@@ -864,15 +864,6 @@ 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
+9
View File
@@ -4525,6 +4525,15 @@ func (guest *SGuest) AllowPerformResizeDisk(ctx context.Context, userCred mcclie
}
func (guest *SGuest) PerformResizeDisk(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input api.ServerResizeDiskInput) (jsonutils.JSONObject, error) {
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")
}
}
if len(input.DiskId) == 0 {
return nil, httperrors.NewMissingParameterError("disk_id")
}