mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
add more log && imcp bugfix
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"fmt"
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/onecloud/pkg/util/huawei/client/auth"
|
||||
"yunion.io/x/onecloud/pkg/util/huawei/client/responses"
|
||||
)
|
||||
@@ -58,9 +59,11 @@ func (self *SServerManager) AsyncCreate(params jsonutils.JSONObject) (string, er
|
||||
|
||||
ret, err := self.CreateInContextWithSpec(nil, "", params, "")
|
||||
if err != nil {
|
||||
log.Debugf("AsyncCreate %s", err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
log.Debugf("AsyncCreate result %s", ret.String())
|
||||
// 按需机器
|
||||
jobId, err := ret.GetString("job_id")
|
||||
if err == nil {
|
||||
|
||||
@@ -590,6 +590,11 @@ func (self *SRegion) addSecurityGroupRules(secGrpId string, rule *secrules.Secur
|
||||
protocal = ""
|
||||
}
|
||||
|
||||
// imcp协议默认为any
|
||||
if rule.Protocol == secrules.PROTO_ICMP {
|
||||
return self.addSecurityGroupRule(secGrpId, direction, "-1", "-1", protocal, rule.IPNet.String())
|
||||
}
|
||||
|
||||
if len(rule.Ports) > 0 {
|
||||
for _, port := range rule.Ports {
|
||||
portStr := fmt.Sprintf("%d", port)
|
||||
@@ -610,7 +615,6 @@ func (self *SRegion) addSecurityGroupRules(secGrpId string, rule *secrules.Secur
|
||||
return nil
|
||||
}
|
||||
|
||||
// todo: icmp协议目前存在差异,华为云能指定icmp code,onecloud不支持
|
||||
func (self *SRegion) addSecurityGroupRule(secGrpId, direction, portStart, portEnd, protocol, ipNet string) error {
|
||||
params := jsonutils.NewDict()
|
||||
secgroupObj := jsonutils.NewDict()
|
||||
|
||||
@@ -203,6 +203,16 @@ func (self *SSecurityGroup) GetSecurityRule(ruleId string, withRuleId bool) (sec
|
||||
protocol = remoteRule.Protocol
|
||||
}
|
||||
|
||||
var portStart int
|
||||
var portEnd int
|
||||
if protocol == secrules.PROTO_ICMP {
|
||||
portStart = -1
|
||||
portEnd = -1
|
||||
} else {
|
||||
portStart = int(remoteRule.PortRangeMin)
|
||||
portEnd = int(remoteRule.PortRangeMax)
|
||||
}
|
||||
|
||||
ipNet := &net.IPNet{}
|
||||
if len(remoteRule.RemoteIPPrefix) > 0 {
|
||||
_, ipNet, err = net.ParseCIDR(remoteRule.RemoteIPPrefix)
|
||||
@@ -221,15 +231,15 @@ func (self *SSecurityGroup) GetSecurityRule(ruleId string, withRuleId bool) (sec
|
||||
} else {
|
||||
desc = remoteRule.Description
|
||||
}
|
||||
// todo: icmp 可能不兼容。华为云能指定icmp code,但是onecloud端不支持
|
||||
|
||||
rule := secrules.SecurityRule{
|
||||
Priority: 1,
|
||||
Action: secrules.SecurityRuleAllow,
|
||||
IPNet: ipNet,
|
||||
Protocol: protocol,
|
||||
Direction: direction,
|
||||
PortStart: int(remoteRule.PortRangeMin),
|
||||
PortEnd: int(remoteRule.PortRangeMax),
|
||||
PortStart: portStart,
|
||||
PortEnd: portEnd,
|
||||
Ports: nil,
|
||||
Description: desc,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user