mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 02:37:24 +08:00
huawei&qcloud&huawei elb bugfix
This commit is contained in:
@@ -235,6 +235,9 @@ type LoadbalancerCreateInput struct {
|
||||
// 套餐名称
|
||||
LoadbalancerSpec string `json:"loadbalancer_spec"`
|
||||
|
||||
// EIP ID
|
||||
Eip string `json:"eip"`
|
||||
|
||||
// LB的其他配置信息
|
||||
LBInfo jsonutils.JSONObject `json:"lb_info"`
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/compare"
|
||||
"yunion.io/x/pkg/utils"
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
@@ -423,7 +424,8 @@ func (lb *SLoadbalancer) GetCreateLoadbalancerParams(iRegion cloudprovider.IClou
|
||||
if lb.ChargeType == api.LB_CHARGE_TYPE_BY_BANDWIDTH {
|
||||
params.EgressMbps = lb.EgressMbps
|
||||
}
|
||||
if lb.AddressType == api.LB_ADDR_TYPE_INTRANET || lb.SManagedResourceBase.GetProviderName() == api.CLOUD_PROVIDER_HUAWEI || lb.SManagedResourceBase.GetProviderName() == api.CLOUD_PROVIDER_AWS {
|
||||
|
||||
if lb.AddressType == api.LB_ADDR_TYPE_INTRANET || utils.IsInStringArray(lb.SManagedResourceBase.GetProviderName(), []string{api.CLOUD_PROVIDER_HUAWEI, api.CLOUD_PROVIDER_AWS, api.CLOUD_PROVIDER_QCLOUD}) {
|
||||
vpc := lb.GetVpc()
|
||||
if vpc == nil {
|
||||
return nil, fmt.Errorf("failed to find vpc for lb %s", lb.Name)
|
||||
@@ -433,6 +435,9 @@ func (lb *SLoadbalancer) GetCreateLoadbalancerParams(iRegion cloudprovider.IClou
|
||||
return nil, err
|
||||
}
|
||||
params.VpcID = iVpc.GetId()
|
||||
}
|
||||
|
||||
if lb.AddressType == api.LB_ADDR_TYPE_INTRANET || utils.IsInStringArray(lb.SManagedResourceBase.GetProviderName(), []string{api.CLOUD_PROVIDER_HUAWEI, api.CLOUD_PROVIDER_AWS}) {
|
||||
networks, err := lb.GetNetworks()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to find network for lb %s: %s", lb.Name, err)
|
||||
|
||||
@@ -85,6 +85,7 @@ func validateAwsLbNetwork(ownerId mcclient.IIdentityProvider, data *jsonutils.JS
|
||||
q = q.Join(wires, sqlchemy.Equals(q.Field("wire_id"), wires.Field("id")))
|
||||
q = q.Filter(sqlchemy.Equals(wires.Field("vpc_id"), vpc.GetId()))
|
||||
q = q.Filter(sqlchemy.NotEquals(wires.Field("zone_id"), zone.GetId()))
|
||||
q = q.Equals("project_id", network.ProjectId)
|
||||
err := q.First(secondNet)
|
||||
if err != nil {
|
||||
return nil, httperrors.NewInputParameterError("required at least %d subnet.", requiredMin)
|
||||
|
||||
@@ -1850,20 +1850,20 @@ func (self *SHuaWeiRegionDriver) RequestCreateLoadbalancer(ctx context.Context,
|
||||
taskman.LocalTaskRun(task, func() (jsonutils.JSONObject, error) {
|
||||
iRegion, err := lb.GetIRegion()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrap(err, "Huawei.RequestCreateLoadbalancer.GetIRegion")
|
||||
}
|
||||
params, err := lb.GetCreateLoadbalancerParams(iRegion)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrap(err, "Huawei.RequestCreateLoadbalancer.GetCreateLoadbalancerParams")
|
||||
}
|
||||
iLoadbalancer, err := iRegion.CreateILoadBalancer(params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrap(err, "Huawei.RequestCreateLoadbalancer.CreateILoadBalancer")
|
||||
}
|
||||
|
||||
lb.SetModelManager(models.LoadbalancerManager, lb)
|
||||
if err := db.SetExternalId(lb, userCred, iLoadbalancer.GetGlobalId()); err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrap(err, "Huawei.RequestCreateLoadbalancer.SetExternalId")
|
||||
}
|
||||
|
||||
{
|
||||
@@ -1872,7 +1872,7 @@ func (self *SHuaWeiRegionDriver) RequestCreateLoadbalancer(ctx context.Context,
|
||||
if len(eipId) > 0 {
|
||||
ieip, err := iRegion.GetIEipById(eipId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrap(err, "Huawei.RequestCreateLoadbalancer.GetIEipById")
|
||||
}
|
||||
|
||||
conf := &cloudprovider.AssociateConfig{
|
||||
@@ -1882,27 +1882,27 @@ func (self *SHuaWeiRegionDriver) RequestCreateLoadbalancer(ctx context.Context,
|
||||
|
||||
err = ieip.Associate(conf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrap(err, "Huawei.RequestCreateLoadbalancer.Associate")
|
||||
}
|
||||
|
||||
eip, err := db.FetchByExternalId(models.ElasticipManager, ieip.GetGlobalId())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrap(err, "Huawei.RequestCreateLoadbalancer.FetchByExternalId")
|
||||
}
|
||||
|
||||
err = eip.(*models.SElasticip).SyncWithCloudEip(ctx, userCred, lb.GetCloudprovider(), ieip, lb.GetOwnerId())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrap(err, "Huawei.RequestCreateLoadbalancer.SyncWithCloudEip")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := lb.SyncWithCloudLoadbalancer(ctx, userCred, iLoadbalancer, nil, lb.GetCloudprovider()); err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrap(err, "Huawei.RequestCreateLoadbalancer.SyncWithCloudLoadbalancer")
|
||||
}
|
||||
lbbgs, err := iLoadbalancer.GetILoadBalancerBackendGroups()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrap(err, "Huawei.RequestCreateLoadbalancer.GetILoadBalancerBackendGroups")
|
||||
}
|
||||
if len(lbbgs) > 0 {
|
||||
provider := lb.GetCloudprovider()
|
||||
|
||||
@@ -753,7 +753,7 @@ func (self *SQcloudRegionDriver) ValidateUpdateLoadbalancerListenerData(ctx cont
|
||||
return nil, httperrors.NewInputParameterError("backend group %s(%s) belongs to loadbalancer %s instead of %s",
|
||||
lbbg.Name, lbbg.Id, lbbg.LoadbalancerId, lblis.LoadbalancerId)
|
||||
} else {
|
||||
if utils.IsInStringArray(lblis.ListenerType, []string{api.LB_LISTENER_TYPE_TCP, api.LB_LISTENER_TYPE_UDP}) {
|
||||
if lbbg != nil && utils.IsInStringArray(lblis.ListenerType, []string{api.LB_LISTENER_TYPE_TCP, api.LB_LISTENER_TYPE_UDP}) {
|
||||
cachedLbbgs, err := lbbg.GetQcloudCachedlbbg()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -6,11 +6,12 @@ package apis
|
||||
import (
|
||||
context "context"
|
||||
fmt "fmt"
|
||||
math "math"
|
||||
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
math "math"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
|
||||
@@ -878,7 +878,7 @@ func (self *SRegion) CreateLoadBalancer(loadbalancer *cloudprovider.SLoadbalance
|
||||
ret := SLoadbalancer{}
|
||||
subnet, err := self.getNetwork(loadbalancer.NetworkIDs[0])
|
||||
if err != nil {
|
||||
return ret, err
|
||||
return ret, errors.Wrap(err, "SRegion.CreateLoadBalancer.getNetwork")
|
||||
}
|
||||
|
||||
params := jsonutils.NewDict()
|
||||
@@ -893,7 +893,7 @@ func (self *SRegion) CreateLoadBalancer(loadbalancer *cloudprovider.SLoadbalance
|
||||
|
||||
err = DoCreate(self.ecsClient.Elb.Create, params, &ret)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
return ret, errors.Wrap(err, "SRegion.CreateLoadBalancer.DoCreate")
|
||||
}
|
||||
|
||||
ret.region = self
|
||||
@@ -902,7 +902,7 @@ func (self *SRegion) CreateLoadBalancer(loadbalancer *cloudprovider.SLoadbalance
|
||||
if len(loadbalancer.EipID) > 0 {
|
||||
err := self.AssociateEipWithPortId(loadbalancer.EipID, ret.VipPortID)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
return ret, errors.Wrap(err, "SRegion.CreateLoadBalancer.AssociateEipWithPortId")
|
||||
}
|
||||
}
|
||||
return ret, nil
|
||||
|
||||
Reference in New Issue
Block a user