mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #1118 in YUNIONIO/onecloud from ~TANGBIN/onecloud:bugfix/tb-huawei-icmp-bugfix to release/2.6.0
* commit '7d4faf7038223e6ecae1827c2504df9a4eeb663d': prepay vm bugfix add more log 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 {
|
||||
|
||||
@@ -754,7 +754,8 @@ func (self *SRegion) CreateInstance(name string, imageId string, instanceType st
|
||||
ids, err = self.GetAllSubTaskEntityIDs(self.ecsClient.Servers.ServiceType(), _id, "server_id")
|
||||
} else {
|
||||
// 包年包月
|
||||
err = cloudprovider.WaitCreated(10*time.Second, 180*time.Second, func() bool {
|
||||
err = cloudprovider.WaitCreated(10*time.Second, 300*time.Second, func() bool {
|
||||
log.Debugf("WaitCreated %s", _id)
|
||||
order, e := self.GetOrder(_id)
|
||||
if e != nil {
|
||||
log.Debugf(e.Error())
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
)
|
||||
|
||||
@@ -138,6 +139,8 @@ func (self *SRegion) GetAllResByOrderId(orderId string) ([]SResource, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Debugf("GetAllResByOrderId %s", order.Resources)
|
||||
return order.Resources, nil
|
||||
}
|
||||
|
||||
@@ -166,7 +169,9 @@ func (self *SRegion) getAllResIdsByType(orderId string, resourceType string) ([]
|
||||
|
||||
ids := make([]string, 0)
|
||||
for _, r := range res {
|
||||
ids = append(ids, r.ResourceID)
|
||||
if len(r.ResourceID) > 0 {
|
||||
ids = append(ids, r.ResourceID)
|
||||
}
|
||||
}
|
||||
|
||||
return ids, 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,
|
||||
}
|
||||
|
||||
@@ -125,7 +125,8 @@ func doListPart(doList listFunc, queries map[string]string, result interface{})
|
||||
|
||||
func DoGet(doGet getFunc, id string, queries map[string]string, result interface{}) error {
|
||||
if len(id) == 0 {
|
||||
return fmt.Errorf(" id should not be empty")
|
||||
resultType := reflect.Indirect(reflect.ValueOf(result)).Type()
|
||||
return fmt.Errorf(" Get %s id should not be empty", resultType.Name())
|
||||
}
|
||||
|
||||
ret, err := doGet(id, queries)
|
||||
|
||||
Reference in New Issue
Block a user