增加CPU、内存变更判断

This commit is contained in:
TangBin
2018-08-20 15:10:46 +08:00
parent 8feaa3538b
commit d33757fbbb
2 changed files with 6 additions and 6 deletions
+6 -5
View File
@@ -342,7 +342,6 @@ func (self *SAliyunGuestDriver) RequestChangeVmConfig(ctx context.Context, guest
config.InstanceId = guest.GetExternalId()
config.Cpu = int(vcpuCount)
config.Memory = int(vmemSize)
// taskman localTaskRun
ihost, err := guest.GetHost().GetIHost()
if err != nil {
return err
@@ -353,11 +352,13 @@ func (self *SAliyunGuestDriver) RequestChangeVmConfig(ctx context.Context, guest
return err
}
err = iVM.ChangeConfig(config.InstanceId, config.Cpu, config.Memory)
// todo: wait status ready & check disk
if err != nil {
return err
if int(guest.VcpuCount) != config.Cpu || guest.VmemSize != config.Memory {
err = iVM.ChangeConfig(config.InstanceId, config.Cpu, config.Memory)
if err != nil {
return err
}
}
log.Debugf("VMchangeConfig %s, wait status ready ...", iVM.GetGlobalId())
err = cloudprovider.WaitStatus(iVM, models.VM_READY, time.Second*5, time.Second*300)
if err != nil {
-1
View File
@@ -583,7 +583,6 @@ func (self *SRegion) DeployVM(instanceId string, name string, password string, k
}
if len(params) > 0 {
log.Debugf("DeployVM with params %s", params)
return self.modifyInstanceAttribute(instanceId, params)
} else {
return nil