| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- // Copyright 2019 Yunion
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- package compute
- import (
- "yunion.io/x/jsonutils"
- "yunion.io/x/onecloud/pkg/apis"
- "yunion.io/x/onecloud/pkg/apis/billing"
- billing_api "yunion.io/x/onecloud/pkg/apis/billing"
- "yunion.io/x/onecloud/pkg/util/ansible"
- )
- type LoadbalancerAgentDeployInput struct {
- apis.Meta
- Host ansible.Host `json:"host"`
- DeployMethod string `json:"deploy_method"`
- }
- const (
- DeployMethodYum = "yum"
- DeployMethodCopy = "copy"
- )
- type LoadbalancerListInput struct {
- apis.VirtualResourceListInput
- apis.ExternalizedResourceBaseListInput
- apis.DeletePreventableResourceBaseListInput
- billing.BillingResourceListInput
- VpcFilterListInput
- ZonalFilterListBase
- NetworkFilterListBase
- // filter by cluster
- Cluster string `json:"cluster"`
- Address []string `json:"address"`
- // 地址类型
- AddressType []string `json:"address_type"`
- // 网络类型
- NetworkType []string `json:"network_type"`
- // 计费类型
- ChargeType []string `json:"charge_type"`
- // 套餐名称
- LoadbalancerSpec []string `json:"loadbalancer_spec"`
- // filter by security group
- SecgroupId string `json:"secgroup_id"`
- // filter for EIP
- WithEip *bool `json:"with_eip"`
- WithoutEip *bool `json:"without_eip"`
- EipAssociable *bool `json:"eip_associable"`
- UsableLoadbalancerForEip string `json:"usable_loadbalancer_for_eip"`
- }
- type LbEip struct {
- // 公网IP地址
- Eip string `json:"eip"`
- EipId string `json:"eip_id"`
- // 公网IP地址类型: 弹性、非弹性
- // example: public_ip
- EipMode string `json:"eip_mode"`
- }
- type LoadbalancerDetails struct {
- apis.VirtualResourceDetails
- ManagedResourceInfo
- LoadbalancerClusterResourceInfo
- VpcResourceInfoBase
- CloudregionResourceInfo
- ZoneResourceInfoBase
- Zone1ResourceInfoBase
- NetworkResourceInfoBase
- SLoadbalancer
- LbEip
- Eips []LbEip `json:"eips"`
- // 后端服务器组名称
- BackendGroup string `json:"backend_group"`
- // 关联安全组列表
- Secgroups []SimpleSecurityGroup `json:"secgroups"`
- LoadbalancerUsage
- }
- type LoadbalancerUsage struct {
- BackendGroupCount int `json:"backend_group_count"`
- ListenerCount int `json:"listener_count"`
- }
- type SimpleSecurityGroup struct {
- Id string `json:"id"`
- Name string `json:"name"`
- }
- type LoadbalancerResourceInfo struct {
- // 负载均衡名称
- Loadbalancer string `json:"loadbalancer"`
- // VPC ID
- VpcId string `json:"vpc_id"`
- VpcResourceInfo
- // 可用区ID
- ZoneId string `json:"zone_id"`
- ZoneResourceInfo
- // cloud provider info
- ManagedResourceInfo
- }
- type LoadbalancerResourceInput struct {
- // 负载均衡名称
- LoadbalancerId string `json:"loadbalancer_id"`
- // swagger:ignore
- // Deprecated
- Loadbalancer string `json:"loadbalancer" yunion-deprecated-by:"loadbalancer_id"`
- }
- type LoadbalancerFilterListInput struct {
- VpcFilterListInput
- ZonalFilterListBase
- LoadbalancerResourceInput
- // 以负载均衡名称排序
- OrderByLoadbalancer string `json:"order_by_loadbalancer"`
- }
- type LoadbalancerCreateInput struct {
- apis.VirtualResourceCreateInput
- // IP地址
- Address string `json:"address"`
- // 地址类型
- AddressType string `json:"address_type"`
- // 网络类型
- NetworkType string `json:"network_type"`
- // 负载均衡集群Id
- ClusterId string `json:"cluster_id"`
- // 计费类型
- ChargeType string `json:"charge_type"`
- // 出口带宽
- EgressMbps int `json:"egress_mbps"`
- // 套餐名称
- LoadbalancerSpec string `json:"loadbalancer_spec"`
- // 弹性公网IP带宽
- // 指定此参数后会创建新的弹性公网IP并绑定到新建的负载均衡
- EipBw int `json:"eip_bw,omitzero"`
- // 弹性公网IP线路类型
- EipBgpType string `json:"eip_bgp_type,omitzero"`
- // 弹性公网IP计费类型
- EipChargeType billing_api.TNetChargeType `json:"eip_charge_type,omitempty"`
- // 是否跟随主机删除而自动释放
- EipAutoDellocate bool `json:"eip_auto_dellocate,omitempty"`
- // swagger:ignore
- Eip string `json:"eip" yunion-deprecated-by:"eip_id"`
- // EIP Id
- EipId string `json:"eip_id"`
- // LB的其他配置信息
- LBInfo jsonutils.JSONObject `json:"lb_info"`
- // 从可用区1
- // required: false
- Zone1 string `json:"zone_1"`
- // 包年包月时长
- Duration string `json:"duration"`
- // swagger:ignore
- BillingType billing_api.TBillingType `json:"billing_type"`
- // swagger:ignore
- BillingCycle string `json:"billing_cycle"`
- VpcResourceInput
- // Vpc string `json:"vpc"`
- ZoneResourceInput
- // Zone string `json:"zone"`
- CloudregionResourceInput
- // Cloudregion string `json:"cloudregion"`
- NetworkResourceInput
- // 多子网
- // swagger:ignore
- Networks []string `json:"networks"`
- // Network string `json:"network"`
- CloudproviderResourceInput
- // Manager string `json:"manager"`
- }
- type LoadbalancerRemoteUpdateInput struct {
- // 是否覆盖替换所有标签
- ReplaceTags *bool `json:"replace_tags" help:"replace all remote tags"`
- }
- type LoadbalancerAssociateEipInput struct {
- // 弹性公网IP的ID
- EipId string `json:"eip_id"`
- // 弹性IP映射的内网IP地址,可选
- IpAddr string `json:"ip_addr"`
- }
- type LoadbalancerCreateEipInput struct {
- // 计费方式,traffic or bandwidth
- ChargeType billing_api.TNetChargeType `json:"charge_type"`
- // Bandwidth
- Bandwidth int64 `json:"bandwidth"`
- // bgp_type
- BgpType string `json:"bgp_type"`
- // auto_dellocate
- AutoDellocate *bool `json:"auto_dellocate"`
- // 弹性IP映射的内网IP地址,可选
- // IpAddr string `json:"ip_addr"`
- }
- type LoadbalancerDissociateEipInput struct {
- // 是否自动释放
- AudoDelete *bool `json:"auto_delete"`
- }
- func (self LoadbalancerDetails) GetMetricTags() map[string]string {
- ret := map[string]string{
- "id": self.Id,
- "elb_id": self.Id,
- "brand": self.Brand,
- "backend_group": self.BackendGroup,
- "cloudregion": self.Cloudregion,
- "domain_id": self.DomainId,
- "project_domain": self.ProjectDomain,
- "region_ext_id": self.RegionExtId,
- "status": self.Status,
- "tenant": self.Project,
- "tenant_id": self.ProjectId,
- "account": self.Account,
- "account_id": self.AccountId,
- "external_id": self.ExternalId,
- }
- return AppendMetricTags(ret, self.MetadataResourceInfo, self.ProjectizedResourceInfo)
- }
|