Merge pull request #1857 from swordqiu/hotfix/qj-esxi-change-instance-type-fail

fix: esxi change instanceType failed as ChangeConfig2 not implemented
This commit is contained in:
yunion-ci-robot
2019-07-23 22:13:07 +08:00
committed by GitHub
+8 -7
View File
@@ -691,19 +691,20 @@ func (self *SManagedVirtualizedGuestDriver) RequestChangeVmConfig(ctx context.Co
}
taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) {
var err error
if len(instanceType) > 0 {
err = iVM.ChangeConfig2(ctx, instanceType)
if err != nil {
return nil, err
}
} else {
}
// no InstanceType
// or InstanceType failed but retry with raw cpu/mem config
if len(instanceType) == 0 || err != nil {
err = iVM.ChangeConfig(ctx, int(vcpuCount), int(vmemSize))
if err != nil {
return nil, err
}
}
err := cloudprovider.WaitCreated(time.Second*5, time.Minute*5, func() bool {
err = cloudprovider.WaitCreated(time.Second*5, time.Minute*5, func() bool {
err := iVM.Refresh()
if err != nil {
return false
@@ -718,9 +719,9 @@ func (self *SManagedVirtualizedGuestDriver) RequestChangeVmConfig(ctx context.Co
return nil, err
}
instanceType := iVM.GetInstanceType()
instanceType = iVM.GetInstanceType()
if len(instanceType) > 0 {
_, err := db.Update(guest, func() error {
_, err = db.Update(guest, func() error {
guest.InstanceType = instanceType
return nil
})