mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): check instancesnapshot in correct place when resize disk
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -4520,6 +4520,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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user