diff --git a/pkg/util/huawei/client/modules/mod_servers.go b/pkg/util/huawei/client/modules/mod_servers.go index e95cb12832..a1cddb8e40 100644 --- a/pkg/util/huawei/client/modules/mod_servers.go +++ b/pkg/util/huawei/client/modules/mod_servers.go @@ -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 { diff --git a/pkg/util/huawei/instance.go b/pkg/util/huawei/instance.go index 12814f44ac..6bfa34d8b8 100644 --- a/pkg/util/huawei/instance.go +++ b/pkg/util/huawei/instance.go @@ -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()) diff --git a/pkg/util/huawei/order.go b/pkg/util/huawei/order.go index c408cfb865..ff66b1932f 100644 --- a/pkg/util/huawei/order.go +++ b/pkg/util/huawei/order.go @@ -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 diff --git a/pkg/util/huawei/region.go b/pkg/util/huawei/region.go index 48967db46b..8ce53de831 100644 --- a/pkg/util/huawei/region.go +++ b/pkg/util/huawei/region.go @@ -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() diff --git a/pkg/util/huawei/securitygroup.go b/pkg/util/huawei/securitygroup.go index 96f852a263..63769e5808 100644 --- a/pkg/util/huawei/securitygroup.go +++ b/pkg/util/huawei/securitygroup.go @@ -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, } diff --git a/pkg/util/huawei/utils.go b/pkg/util/huawei/utils.go index a7c0eac780..63bdd69af0 100644 --- a/pkg/util/huawei/utils.go +++ b/pkg/util/huawei/utils.go @@ -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)