mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
Automatic merge from release/2.6.0 -> release/2.7.0
* commit '65188bd7c267f3c76aa84003148ebd7b959dd564': 忽略deny规则 避免创建vpc后wire同步异常 openstack重置密码不需要重启机器 修复套餐系统盘盘大小异常问题
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
|
||||
}
|
||||
|
||||
@@ -76,6 +76,10 @@ func (self *SOpenStackGuestDriver) GetChangeConfigStatus() ([]string, error) {
|
||||
return []string{models.VM_READY, models.VM_RUNNING}, nil
|
||||
}
|
||||
|
||||
func (self *SOpenStackGuestDriver) IsNeedRestartForResetLoginInfo() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SOpenStackGuestDriver) GetDeployStatus() ([]string, error) {
|
||||
return []string{models.VM_RUNNING}, nil
|
||||
}
|
||||
|
||||
@@ -358,9 +358,11 @@ func (self *SGuest) PerformDeploy(ctx context.Context, userCred mcclient.TokenCr
|
||||
}
|
||||
|
||||
if utils.IsInStringArray(self.Status, deployStatus) {
|
||||
if (doRestart && self.Status == VM_RUNNING) ||
|
||||
jsonutils.QueryBoolean(kwargs, "auto_start", false) {
|
||||
if (doRestart && self.Status == VM_RUNNING) || (self.Status != VM_RUNNING && (jsonutils.QueryBoolean(kwargs, "auto_start", false) || jsonutils.QueryBoolean(kwargs, "restart", false))) {
|
||||
kwargs.Set("restart", jsonutils.JSONTrue)
|
||||
} else {
|
||||
// 避免前端直接传restart参数, 越过校验
|
||||
kwargs.Set("restart", jsonutils.JSONFalse)
|
||||
}
|
||||
err := self.StartGuestDeployTask(ctx, userCred, kwargs, "deploy", "")
|
||||
if err != nil {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -171,12 +171,16 @@ func (region *SRegion) GetIStoragecaches() ([]cloudprovider.ICloudStoragecache,
|
||||
}
|
||||
|
||||
func (region *SRegion) GetIVpcById(id string) (cloudprovider.ICloudVpc, error) {
|
||||
vpc, err := region.GetVpc(id)
|
||||
ivpcs, err := region.GetIVpcs()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
vpc.region = region
|
||||
return vpc, nil
|
||||
for i := 0; i < len(ivpcs); i++ {
|
||||
if ivpcs[i].GetGlobalId() == id {
|
||||
return ivpcs[i], nil
|
||||
}
|
||||
}
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
|
||||
func (region *SRegion) GetIZoneById(id string) (cloudprovider.ICloudZone, error) {
|
||||
|
||||
@@ -296,6 +296,10 @@ func (region *SRegion) delSecurityGroupRule(ruleId string) error {
|
||||
}
|
||||
|
||||
func (region *SRegion) addSecurityGroupRules(secgroupId string, rule *secrules.SecurityRule) error {
|
||||
if rule.Action == secrules.SecurityRuleDeny {
|
||||
// openstack 不支持deny规则
|
||||
return nil
|
||||
}
|
||||
direction := "ingress"
|
||||
if rule.Direction == secrules.SecurityRuleEgress {
|
||||
direction = "egress"
|
||||
|
||||
Reference in New Issue
Block a user