mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 10:46:58 +08:00
fix: 避免华为云安全组规则删除失败
This commit is contained in:
@@ -712,7 +712,16 @@ func (self *SRegion) CreateSecurityGroup(vpcId string, name string, desc string)
|
||||
|
||||
// https://support.huaweicloud.com/api-vpc/zh-cn_topic_0087467071.html
|
||||
func (self *SRegion) delSecurityGroupRule(secGrpRuleId string) error {
|
||||
return DoDelete(self.ecsClient.SecurityGroupRules.Delete, secGrpRuleId, nil, nil)
|
||||
_, err := self.ecsClient.SecurityGroupRules.DeleteInContextWithSpec(nil, secGrpRuleId, "", nil, nil, "")
|
||||
return err
|
||||
}
|
||||
|
||||
func (self *SRegion) DeleteSecurityGroupRule(ruleId string) error {
|
||||
return self.delSecurityGroupRule(ruleId)
|
||||
}
|
||||
|
||||
func (self *SRegion) CreateSecurityGroupRule(secgroupId string, rule cloudprovider.SecurityRule) error {
|
||||
return self.addSecurityGroupRules(secgroupId, rule)
|
||||
}
|
||||
|
||||
// https://support.huaweicloud.com/api-vpc/zh-cn_topic_0087451723.html
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
package shell
|
||||
|
||||
import (
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/secrules"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/multicloud/huawei"
|
||||
"yunion.io/x/onecloud/pkg/util/shellutils"
|
||||
)
|
||||
@@ -59,4 +63,28 @@ func init() {
|
||||
return nil
|
||||
})
|
||||
|
||||
type SecurityGroupRuleIdOptions struct {
|
||||
ID string
|
||||
}
|
||||
|
||||
shellutils.R(&SecurityGroupRuleIdOptions{}, "security-group-rule-delete", "Delete security group rule", func(cli *huawei.SRegion, args *SecurityGroupRuleIdOptions) error {
|
||||
return cli.DeleteSecurityGroupRule(args.ID)
|
||||
})
|
||||
|
||||
type SecurityGroupRuleCreateOptions struct {
|
||||
SECGROUP_ID string
|
||||
RULE string
|
||||
}
|
||||
|
||||
shellutils.R(&SecurityGroupRuleCreateOptions{}, "security-group-rule-create", "Create security group rule", func(cli *huawei.SRegion, args *SecurityGroupRuleCreateOptions) error {
|
||||
_rule, err := secrules.ParseSecurityRule(args.RULE)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "invalid rule %s", args.RULE)
|
||||
}
|
||||
rule := cloudprovider.SecurityRule{
|
||||
SecurityRule: *_rule,
|
||||
}
|
||||
return cli.CreateSecurityGroupRule(args.SECGROUP_ID, rule)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user