fix: aliyun lb charge type

This commit is contained in:
Qu Xuan
2021-04-14 17:59:11 +08:00
parent 1e3e541e1c
commit 7c4e4645bf
+27 -15
View File
@@ -78,10 +78,12 @@ type SLoadbalancer struct {
MasterZoneId string //实例的主可用区ID。
SlaveZoneId string //实例的备可用区ID。
InternetChargeType TInternetChargeType //公网实例的计费方式。取值:paybybandwidth:按带宽计费 paybytraffic:按流量计费(默认值) 说明 当 PayType参数的值为PrePay时,只支持按带宽计费。
PayType string //实例的计费类型,取值:PayOnDemand:按量付费 PrePay:预付费
ResourceGroupId string //企业资源组ID。
LoadBalancerSpec string //负载均衡实例的的性能规格
Bandwidth int //按带宽计费的公网型实例的带宽峰值
InternetChargeTypeAlias TInternetChargeType
PayType string //实例的计费类型,取值:PayOnDemand:按量付费 PrePay:预付费
ResourceGroupId string //企业资源组ID。
LoadBalancerSpec string //负载均衡实例的的性能规格
Bandwidth int //按带宽计费的公网型实例的带宽峰值
}
func (lb *SLoadbalancer) GetName() string {
@@ -268,13 +270,18 @@ func (lb *SLoadbalancer) GetLoadbalancerSpec() string {
}
func (lb *SLoadbalancer) GetChargeType() string {
switch lb.InternetChargeType {
chargeType := lb.InternetChargeType
if len(lb.InternetChargeTypeAlias) > 0 {
chargeType = lb.InternetChargeTypeAlias
}
switch chargeType {
case "paybybandwidth":
return api.LB_CHARGE_TYPE_BY_BANDWIDTH
case "paybytraffic":
return api.LB_CHARGE_TYPE_BY_TRAFFIC
default:
return string(chargeType)
}
return "unknown"
}
func (lb *SLoadbalancer) GetCreatedAt() time.Time {
@@ -304,15 +311,20 @@ func (lb *SLoadbalancer) GetILoadBalancerBackendGroupById(groupId string) (cloud
func (lb *SLoadbalancer) GetIEIP() (cloudprovider.ICloudEIP, error) {
if lb.AddressType == "internet" {
eip := SEipAddress{
region: lb.region,
IpAddress: lb.Address,
InstanceId: lb.GetGlobalId(),
InstanceType: EIP_INTANNCE_TYPE_SLB,
Status: EIP_STATUS_INUSE,
AllocationId: lb.GetGlobalId(),
AllocationTime: lb.CreateTime,
Bandwidth: lb.Bandwidth,
InternetChargeType: lb.InternetChargeType,
region: lb.region,
IpAddress: lb.Address,
InstanceId: lb.GetGlobalId(),
InstanceType: EIP_INTANNCE_TYPE_SLB,
Status: EIP_STATUS_INUSE,
AllocationId: lb.GetGlobalId(),
AllocationTime: lb.CreateTime,
Bandwidth: lb.Bandwidth,
}
switch lb.GetChargeType() {
case api.LB_CHARGE_TYPE_BY_BANDWIDTH:
eip.InternetChargeType = InternetChargeByBandwidth
case api.LB_CHARGE_TYPE_BY_TRAFFIC:
eip.InternetChargeType = InternetChargeByTraffic
}
return &eip, nil
}