diff --git a/pkg/compute/models/disks.go b/pkg/compute/models/disks.go index f96b476832..e85cafda19 100644 --- a/pkg/compute/models/disks.go +++ b/pkg/compute/models/disks.go @@ -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 diff --git a/pkg/compute/models/guest_actions.go b/pkg/compute/models/guest_actions.go index 648ce06945..215fdeceab 100644 --- a/pkg/compute/models/guest_actions.go +++ b/pkg/compute/models/guest_actions.go @@ -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") }