elasticip.go 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package compute
  15. import (
  16. "yunion.io/x/onecloud/pkg/apis"
  17. billing_api "yunion.io/x/onecloud/pkg/apis/billing"
  18. )
  19. type SElasticipCreateInput struct {
  20. apis.VirtualResourceCreateInput
  21. // 区域名称或Id, 建议使用Id
  22. // 在指定区域内创建弹性公网ip
  23. CloudregionId string `json:"cloudregion_id"`
  24. // swagger:ignore
  25. Cloudregion string `json:"cloudregion" yunion-deprecated-by:"cloudregion_id"`
  26. // swagger:ignore
  27. Region string `json:"region" yunion-deprecated-by:"cloudregion_id"`
  28. // swagger:ignore
  29. RegionId string `json:"region_id" yunion-deprecated-by:"cloudregion_id"`
  30. // swagger:ignore
  31. Cloudprovider string `json:"cloudprovider" yunion-deprecated-by:"manager_id"`
  32. // swagger:ignore
  33. Manager string `json:"manager" yunion-deprecated-by:"manager_id"`
  34. // 子订阅Id, 建议使用Id
  35. // 使用指定子订阅创建弹性公网ip
  36. // 弹性公网ip和虚拟机在同一区域同一子订阅底下,才可以进行绑定操作
  37. ManagerId string `json:"manager_id"`
  38. // 计费类型: 流量或带宽
  39. //
  40. //
  41. //
  42. // | 平台 | 支持类型 |
  43. // | --- | -------- |
  44. // |Aliyun | traffic, bandwidth |
  45. // |腾讯云 | traffic |
  46. // |Azure | traffic |
  47. // |Google | traffic, bandwidth |
  48. // |Ucloud | traffic |
  49. // |Aws | traffic |
  50. // |华为云 | traffic, bandwidth |
  51. // |天翼云 | traffic, bandwidth |
  52. // |KVM | 不支持创建 |
  53. // |VMware | 不支持创建 |
  54. // |ZStack | traffic |
  55. // |OpenStack | traffic |
  56. // default: traffic
  57. // enum: ["traffic", "bandwidth"]
  58. ChargeType billing_api.TNetChargeType `json:"charge_type"`
  59. Mode string `json:"mode"`
  60. // swagger:ignore
  61. Network string `json:"network" yunion-deprecated-by:"network_id"`
  62. // 子网Id
  63. // 私有云创建此参数必传,例如Openstack, ZStack
  64. NetworkId string `json:"network_id"`
  65. // 指定新建EIP的地址
  66. IpAddr string `json:"ip_addr"`
  67. // 线路类型
  68. //
  69. //
  70. //
  71. // | 平台 | 支持类型 | 说明 |
  72. // | --- | -------- | --- |
  73. // |Aliyun | BGP, BGP_PRO(精品线路) | 部分区域不支持BGP_PRO|
  74. // default: BGP
  75. BgpType string `json:"bgp_type"`
  76. BandwidthMb int `json:"bandwidth"`
  77. }
  78. type ElasticipDetails struct {
  79. apis.VirtualResourceDetails
  80. ManagedResourceInfo
  81. CloudregionResourceInfo
  82. SElasticip
  83. // 绑定资源名称
  84. AssociateName string `json:"associate_name"`
  85. // 虚拟机内网IP
  86. ServerPrivateIp string `json:"server_private_ip"`
  87. }
  88. func (self ElasticipDetails) GetMetricTags() map[string]string {
  89. ret := map[string]string{
  90. "id": self.Id,
  91. "name": self.Name,
  92. "status": self.Status,
  93. "mode": self.Mode,
  94. "cloudregion": self.Cloudregion,
  95. "cloudregion_id": self.CloudregionId,
  96. "region_ext_id": self.RegionExtId,
  97. "tenant": self.Project,
  98. "tenant_id": self.ProjectId,
  99. "brand": self.Brand,
  100. "domain_id": self.DomainId,
  101. "project_domain": self.ProjectDomain,
  102. "ip_addr": self.IpAddr,
  103. "external_id": self.ExternalId,
  104. }
  105. return AppendMetricTags(ret, self.MetadataResourceInfo, self.ProjectizedResourceInfo)
  106. }
  107. type ElasticipSyncstatusInput struct {
  108. }
  109. type ElasticipAssociateInput struct {
  110. // 待绑定实例Id
  111. InstanceId string `json:"instance_id"`
  112. // swagger:ignore
  113. InstanceExternalId string `json:"instance_external_id"`
  114. // swagger:ignore
  115. Instance string `json:"instance" yunion-deprecated-by:"instance_id"`
  116. // 实例类型
  117. // enmu: server, natgateway
  118. // default: server
  119. InstanceType string `json:"instance_type"`
  120. // EIP映射的内网IP地址,可选
  121. IpAddr string `json:"ip_addr"`
  122. }
  123. type ElasticDissociateInput struct {
  124. // 注意: 若关联到aws NAT网关后,目前没办法解除关联关系
  125. // 是否解绑后自动删除弹性公网IP
  126. // default: false
  127. AutoDelete bool `json:"auto_delete"`
  128. }
  129. type ElasticipRemoteUpdateInput struct {
  130. // 是否覆盖替换所有标签
  131. ReplaceTags *bool `json:"replace_tags" help:"replace all remote tags"`
  132. }