fix: 避免有些云不能创建default名称安全组

This commit is contained in:
Qu Xuan
2019-11-15 10:29:58 +08:00
parent 60932828ca
commit 983caa0ad5
2 changed files with 6 additions and 0 deletions
@@ -1424,6 +1424,9 @@ func (self *SManagedVirtualizationRegionDriver) RequestSyncSecurityGroup(ctx con
}
if len(cache.ExternalId) == 0 {
if strings.ToLower(secgroup.Name) == "default" { //避免有些云不支持default关键字
secgroup.Name = "DefaultGroup"
}
// 避免有的云不支持重名安全组
groupName := secgroup.Name
for i := 0; i < 30; i++ {
+3
View File
@@ -235,6 +235,9 @@ func (self *SRegion) CreateSecurityGroup(vpcId string, name string, secgroupIdTa
desc = "vpc default group"
}
params.SetDescription(desc)
if strings.ToLower(name) == "default" {
name = randomString(fmt.Sprintf("%s-", vpcId), 9)
}
params.SetGroupName(name)
group, err := self.ec2Client.CreateSecurityGroup(params)