mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-24 23:41:52 +08:00
Merge pull request #18550 from ioito/automated-cherry-pick-of-#18549-upstream-release-3.11
Automated cherry pick of #18549: fix(region): esxi vm resize disk online
This commit is contained in:
@@ -290,7 +290,7 @@ func (self *SESXiGuestDriver) ValidateCreateEip(ctx context.Context, userCred mc
|
||||
}
|
||||
|
||||
func (self *SESXiGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk *models.SDisk, storage *models.SStorage) error {
|
||||
if !utils.IsInStringArray(guest.Status, []string{api.VM_READY}) {
|
||||
if !utils.IsInStringArray(guest.Status, []string{api.VM_READY, api.VM_RUNNING}) {
|
||||
return fmt.Errorf("Cannot resize disk when guest in status %s", guest.Status)
|
||||
}
|
||||
count, err := guest.GetInstanceSnapshotCount()
|
||||
|
||||
@@ -269,6 +269,30 @@ func (self *SESXiHostDriver) RequestResizeDiskOnHost(ctx context.Context, host *
|
||||
if guest == nil {
|
||||
return fmt.Errorf("unable to find guest has disk %s", disk.GetId())
|
||||
}
|
||||
|
||||
iVm, err := guest.GetIVM(ctx)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "GetIVM")
|
||||
}
|
||||
if iVm.GetStatus() == api.VM_RUNNING {
|
||||
taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) {
|
||||
disks, err := iVm.GetIDisks()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "GetIDisk")
|
||||
}
|
||||
for i := range disks {
|
||||
if disks[i].GetGlobalId() == disk.ExternalId {
|
||||
err = disks[i].Resize(ctx, sizeMb)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "Resize")
|
||||
}
|
||||
return jsonutils.Marshal(map[string]int64{"disk_size": sizeMb}), nil
|
||||
}
|
||||
}
|
||||
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "disk %s", disk.Name)
|
||||
})
|
||||
return nil
|
||||
}
|
||||
spec := struct {
|
||||
HostInfo vcenter.SVCenterAccessInfo
|
||||
VMId string
|
||||
|
||||
Reference in New Issue
Block a user