zone.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 "yunion.io/x/onecloud/pkg/apis"
  16. type ZoneCreateInput struct {
  17. apis.StatusStandaloneResourceCreateInput
  18. // 区域名称或Id,建议使用Id
  19. Cloudregion string `json:"cloudregion"`
  20. // swagger:ignore
  21. Region string `json:"region"`
  22. // swagger:ignore
  23. RegionId string `json:"region_id"`
  24. // swagger:ignore
  25. CloudregionId string `json:"cloudregion_id"`
  26. }
  27. type ZoneGeneralUsage struct {
  28. // 可用区底下的宿主机数量
  29. // example: 3
  30. Hosts int `json:"hosts"`
  31. // 可用区底下启用的宿主机数量
  32. // example: 2
  33. HostsEnabled int `json:"hosts_enabled"`
  34. // 可用区底下的裸金属服务器数量
  35. // example: 1
  36. Baremetals int `json:"baremetals"`
  37. // 可用区底下启用的裸金属服务器数量
  38. // example: 1
  39. BaremetalsEnabled int `json:"baremetals_enabled"`
  40. // 可用区底下的二层网络数量
  41. // example: 3
  42. Wires int `json:"wires"`
  43. // 可用区底下的子网数量
  44. // example: 1
  45. Networks int `json:"networks"`
  46. // 可用区底下的块存储数量
  47. // example: 1
  48. Storages int `json:"storages"`
  49. }
  50. func (usage *ZoneGeneralUsage) IsEmpty() bool {
  51. if usage.Hosts > 0 {
  52. return false
  53. }
  54. if usage.Wires > 0 {
  55. return false
  56. }
  57. if usage.Networks > 0 {
  58. return false
  59. }
  60. if usage.Storages > 0 {
  61. return false
  62. }
  63. return true
  64. }
  65. type ZoneDetails struct {
  66. apis.StatusStandaloneResourceDetails
  67. CloudregionResourceInfo
  68. CloudenvResourceInfo
  69. ZoneGeneralUsage
  70. SZone
  71. }
  72. type ZoneResourceInfoBase struct {
  73. // 可用区名称
  74. // example: 北京一区
  75. Zone string `json:"zone"`
  76. // 纳管云的zoneId
  77. ZoneExtId string `json:"zone_ext_id"`
  78. }
  79. type Zone1ResourceInfoBase struct {
  80. // 可用区名称
  81. // example: 北京2区
  82. Zone1Name string `json:"zone_1_name"`
  83. // 纳管云的zoneId
  84. Zone1ExtId string `json:"zone_1_ext_id"`
  85. }
  86. type SlaveZoneResourceInfoBase struct {
  87. // 可用区名称
  88. // example: 北京2区
  89. SlaveZone string `json:"slave_zone"`
  90. // 纳管云的zoneId
  91. SlaveZoneExtId string `json:"slave_zone_ext_id"`
  92. }
  93. type ZoneResourceInfo struct {
  94. ZoneResourceInfoBase
  95. // 可用区的区域ID
  96. CloudregionId string `json:"cloudregion_id"`
  97. CloudregionResourceInfo
  98. }
  99. type ZonePurgeInput struct {
  100. // 云订阅Id, 若zone底下不存在任何资源,会删除当前zone
  101. // required: true
  102. ManagerId string `json:"manager_id"`
  103. }