mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-30 18:23:35 +08:00
修复套餐系统盘盘大小异常问题
This commit is contained in:
@@ -5,10 +5,12 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
CloudVMStatusRunning = "running"
|
||||
CloudVMStatusSuspend = "suspend"
|
||||
CloudVMStatusStopped = "stopped"
|
||||
CloudVMStatusOther = "other"
|
||||
CloudVMStatusRunning = "running"
|
||||
CloudVMStatusSuspend = "suspend"
|
||||
CloudVMStatusStopped = "stopped"
|
||||
CloudVMStatusChangeFlavor = "change_flavor"
|
||||
CloudVMStatusDeploying = "deploying"
|
||||
CloudVMStatusOther = "other"
|
||||
)
|
||||
|
||||
var ErrNotFound = errors.New("id not found")
|
||||
|
||||
@@ -228,6 +228,10 @@ func (self *SManagedVirtualizedGuestDriver) RequestSyncstatusOnHost(ctx context.
|
||||
status = cloudprovider.CloudVMStatusStopped
|
||||
case models.VM_STOPPING:
|
||||
status = cloudprovider.CloudVMStatusRunning
|
||||
case models.VM_CHANGE_FLAVOR:
|
||||
status = cloudprovider.CloudVMStatusChangeFlavor
|
||||
case models.VM_DEPLOYING:
|
||||
status = cloudprovider.CloudVMStatusDeploying
|
||||
default:
|
||||
status = cloudprovider.CloudVMStatusOther
|
||||
}
|
||||
|
||||
@@ -99,6 +99,9 @@ func (region *SRegion) syncFlavor(name string, cpu, memoryMb, diskGB int) (strin
|
||||
}
|
||||
|
||||
func (region *SRegion) CreateFlavor(name string, cpu int, memoryMb int, diskGB int) (*SFlavor, error) {
|
||||
if diskGB < 30 {
|
||||
diskGB = 30
|
||||
}
|
||||
params := map[string]map[string]interface{}{
|
||||
"flavor": {
|
||||
"name": name,
|
||||
|
||||
@@ -156,7 +156,7 @@ func (host *SHost) CreateVM(desc *cloudprovider.SManagedVMCreateConfig) (cloudpr
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sysDiskSizeGB := image.Size / 1024 / 1024
|
||||
sysDiskSizeGB := image.Size / 1024 / 1024 / 1024
|
||||
if desc.SysDisk.SizeGB < sysDiskSizeGB {
|
||||
desc.SysDisk.SizeGB = sysDiskSizeGB
|
||||
}
|
||||
|
||||
@@ -298,8 +298,10 @@ func (instance *SInstance) GetStatus() string {
|
||||
return models.VM_MIGRATING
|
||||
case INSTANCE_STATUS_PAUSED, INSTANCE_STATUS_SUSPENDED:
|
||||
return models.VM_SUSPEND
|
||||
case INSTANCE_STATUS_RESIZE, INSTANCE_STATUS_VERIFY_RESIZE:
|
||||
case INSTANCE_STATUS_RESIZE:
|
||||
return models.VM_CHANGE_FLAVOR
|
||||
case INSTANCE_STATUS_VERIFY_RESIZE:
|
||||
return INSTANCE_STATUS_VERIFY_RESIZE
|
||||
case INSTANCE_STATUS_SHELVED, INSTANCE_STATUS_SHELVED_OFFLOADED, INSTANCE_STATUS_SHUTOFF, INSTANCE_STATUS_SOFT_DELETED:
|
||||
return models.VM_READY
|
||||
default:
|
||||
@@ -412,7 +414,13 @@ func (region *SRegion) ChangeConfig(instance *SInstance, flavorId string) error
|
||||
}
|
||||
_, maxVersion, _ := region.GetVersion("compute")
|
||||
_, _, err := region.Post("compute", fmt.Sprintf("/servers/%s/action", instance.ID), maxVersion, jsonutils.Marshal(params))
|
||||
return err
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := cloudprovider.WaitStatus(instance, INSTANCE_STATUS_VERIFY_RESIZE, time.Second*3, time.Minute*4); err != nil {
|
||||
return err
|
||||
}
|
||||
return region.instanceOperation(instance.ID, "confirmResize")
|
||||
}
|
||||
|
||||
func (instance *SInstance) AttachDisk(ctx context.Context, diskId string) error {
|
||||
|
||||
Reference in New Issue
Block a user