mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #473 in YUNIONIO/onecloud from ~QUXUAN/onecloud:hotfix/qx-azure-disk-resize-validate to release/2.2.0
* commit '4ae235570df4f25c1b0d6b67a5cdc1132a589b10': 根据Azure主机状态判断磁盘是否可以resize
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/util/seclib2"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
@@ -70,6 +71,15 @@ func (self *SAzureGuestDriver) GetDeployStatus() ([]string, error) {
|
||||
return []string{models.VM_RUNNING}, nil
|
||||
}
|
||||
|
||||
func (self *SAzureGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk *models.SDisk, storage *models.SStorage) error {
|
||||
//https://docs.microsoft.com/en-us/rest/api/compute/disks/update
|
||||
//Resizes are only allowed if the disk is not attached to a running VM, and can only increase the disk's size
|
||||
if !utils.IsInStringArray(guest.Status, []string{models.VM_READY}) {
|
||||
return fmt.Errorf("Cannot resize disk when guest in status %s", guest.Status)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SAzureGuestDriver) RequestDetachDisk(ctx context.Context, guest *models.SGuest, task taskman.ITask) error {
|
||||
return guest.StartSyncTask(ctx, task.GetUserCred(), false, task.GetTaskId())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user