mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix: 修复华为云ucloud安全组同步问题
This commit is contained in:
@@ -512,17 +512,17 @@ func (self *SRegion) DeleteSecurityGroup(vpcId, secgroupId string) error {
|
||||
func (self *SRegion) SyncSecurityGroup(secgroupId string, vpcId string, name string, desc string, rules []secrules.SecurityRule) (string, error) {
|
||||
if len(secgroupId) > 0 {
|
||||
_, err := self.GetSecurityGroupDetails(secgroupId)
|
||||
if err == cloudprovider.ErrNotSupported {
|
||||
if err == cloudprovider.ErrNotFound {
|
||||
secgroupId = ""
|
||||
} else if err != nil {
|
||||
return "", err
|
||||
return "", errors.Wrapf(err, "self.GetSecurityGroupDetails(%s)", secgroupId)
|
||||
}
|
||||
}
|
||||
|
||||
if len(secgroupId) == 0 {
|
||||
extID, err := self.CreateSecurityGroup(vpcId, name, desc)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return "", errors.Wrap(err, "self.CreateSecurityGroup")
|
||||
}
|
||||
secgroupId = extID
|
||||
}
|
||||
@@ -708,11 +708,11 @@ func (self *SRegion) syncSecgroupRules(secgroupId string, rules []secrules.Secur
|
||||
var AddRules []secrules.SecurityRule
|
||||
|
||||
if secgroup, err := self.GetSecurityGroupDetails(secgroupId); err != nil {
|
||||
return err
|
||||
return errors.Wrapf(err, "syncSecgroupRules.GetSecurityGroupDetails(%s)", secgroupId)
|
||||
} else {
|
||||
remoteRules, err := secgroup.GetRulesWithExtId()
|
||||
if err != nil {
|
||||
return err
|
||||
return errors.Wrap(err, "secgroup.GetRulesWithExtId")
|
||||
}
|
||||
|
||||
sort.Sort(secrules.SecurityRuleSet(rules))
|
||||
|
||||
@@ -246,6 +246,9 @@ func (self *SRegion) GetSecurityGroups(secGroupId string, resourceId string) ([]
|
||||
}
|
||||
err := self.DoListAll("DescribeFirewall", params, &secgroups)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "not exist") {
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user