as_model.py 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. """
  2. This module provides a model class for AS.
  3. """
  4. class Config(dict):
  5. """
  6. This class defines the Config object within AutoScalingGroupConfig.
  7. """
  8. def __init__(self, min_node_num, expect_num, max_node_num, cooldown_in_sec):
  9. """
  10. :param min_node_num: Minimum number of nodes in the auto scaling group
  11. :type min_node_num: int
  12. :param expect_num: Expected number of nodes in the auto scaling group
  13. :type expect_num: int
  14. ...
  15. :param cooldown_in_sec: Cooldown period in seconds for the auto scaling group
  16. :type cooldown_in_sec: int
  17. """
  18. super(Config, self).__init__()
  19. self["minNodeNum"] = min_node_num
  20. self["expectNum"] = expect_num
  21. self["maxNodeNum"] = max_node_num
  22. self["cooldownInSec"] = cooldown_in_sec
  23. class HealthCheck(dict):
  24. """
  25. This class defines the HealthCheck object within AutoScalingGroupConfig.
  26. """
  27. def __init__(self, health_check_interval, grace_time):
  28. """
  29. :param health_check_interval: Interval for health checks in seconds
  30. :type health_check_interval: int
  31. :param grace_time: Grace period for health checks in seconds
  32. :type grace_time: int
  33. """
  34. super(HealthCheck, self).__init__()
  35. self["healthCheckInterval"] = health_check_interval
  36. self["graceTime"] = grace_time
  37. class ZoneInfo(dict):
  38. """
  39. This class defines the ZoneInfo object.
  40. """
  41. def __init__(self, zone, subnet_id):
  42. """
  43. :param zone: Zone information
  44. :type zone: str
  45. :param subnet_id: Subnet ID
  46. :type subnet_id: str
  47. """
  48. super(ZoneInfo, self).__init__()
  49. self["zone"] = zone
  50. self["subnetId"] = subnet_id
  51. class AssignTagInfo(dict):
  52. """
  53. This class defines the AssignTagInfo object.
  54. """
  55. def __init__(self, relation_tag, tags):
  56. """
  57. :param relation_tag: Relation tag
  58. :type relation_tag: str
  59. :param tags: Tags
  60. :type tags: list
  61. """
  62. super(AssignTagInfo, self).__init__()
  63. self["relationTag"] = relation_tag
  64. self["tags"] = tags
  65. class Tag(dict):
  66. """
  67. This class defines the Tag object.
  68. """
  69. def __init__(self, tag_key, tag_value):
  70. """
  71. :param tag_key: Tag Key
  72. :type tag_key: str
  73. :param tag_value: Tag Value
  74. :type tag_value: str
  75. """
  76. super(Tag, self).__init__()
  77. self["tagKey"] = tag_key
  78. self["tagValue"] = tag_value
  79. class Node(dict):
  80. """
  81. This class defines the Node object.
  82. """
  83. def __init__(self, cpu_count, memory_capacity_in_gb, sys_disk_type, sys_disk_in_gb, instance_type, product_type,
  84. image_id, image_type, os_type, security_group_id, spec, ephemeral_disks, asp_id, priorities,
  85. zone_subnet, total_count, bid_model, bid_price, cds):
  86. """
  87. :param cpu_count: The number of CPU cores
  88. :type cpu_count: int
  89. :param memory_capacity_in_gb: The capacity of the memory in GB
  90. :type memory_capacity_in_gb: int
  91. :param sys_disk_type: The type of the system disk
  92. :type sys_disk_type: str
  93. :param sys_disk_in_gb: The capacity of the system disk in GB
  94. :type sys_disk_in_gb: int
  95. :param instance_type: The type of the instance
  96. :type instance_type: str
  97. :param product_type: The type of the product
  98. :type product_type: str
  99. :param image_id: The ID of the image
  100. :type image_id: str
  101. :param image_type: The type of the image
  102. :type image_type: str
  103. :param os_type: The type of the operating system
  104. :type os_type: str
  105. :param security_group_id: The ID of the security group
  106. :type security_group_id: str
  107. :param spec: The specification
  108. :type spec: str
  109. :param ephemeral_disks: The ephemeral disks
  110. :type ephemeral_disks: list
  111. :param asp_id: The ID of the ASP
  112. :type asp_id: str
  113. :param priorities: The priorities
  114. :type priorities: list
  115. :param zone_subnet: The subnet of the zone
  116. :type zone_subnet: str
  117. :param total_count: The total count
  118. :type total_count: int
  119. :param bid_model: The model of the bid
  120. :type bid_model: str
  121. :param bid_price: The price of the bid
  122. :type bid_price: float
  123. :param cds: The CDS
  124. :type cds: list
  125. """
  126. super(Node, self).__init__()
  127. self["cpuCount"] = cpu_count
  128. self["memoryCapacityInGB"] = memory_capacity_in_gb
  129. self["sysDiskType"] = sys_disk_type
  130. self["sysDiskInGB"] = sys_disk_in_gb
  131. self["instanceType"] = instance_type
  132. self["productType"] = product_type
  133. self["imageId"] = image_id
  134. self["imageType"] = image_type
  135. self["osType"] = os_type
  136. self["securityGroupId"] = security_group_id
  137. self["spec"] = spec
  138. self["ephemeralDisks"] = ephemeral_disks
  139. self["aspId"] = asp_id
  140. self["priorities"] = priorities
  141. self["zoneSubnet"] = zone_subnet
  142. self["totalCount"] = total_count
  143. self["bidModel"] = bid_model
  144. self["bidPrice"] = bid_price
  145. self["cds"] = cds
  146. class Eip(dict):
  147. """
  148. This class defines EIP information.
  149. """
  150. def __init__(self, if_bind_eip, bandwidth_in_mbps, eip_product_type):
  151. """
  152. :param if_bind_eip: if bind eip
  153. :type if_bind_eip: bool
  154. :param bandwidth_in_mbps: bandwidth_in_mbps
  155. :type bandwidth_in_mbps: int
  156. :param eip_product_type: eip_product_type
  157. :type eip_product_type: string
  158. """
  159. super(Eip, self).__init__()
  160. self["ifBindEip"] = if_bind_eip
  161. self["bandwidthInMbps"] = bandwidth_in_mbps
  162. self["eipProductType"] = eip_product_type
  163. class Billing(dict):
  164. """
  165. This class defines the Billing object.
  166. """
  167. def __init__(self, payment_timing):
  168. """
  169. :param payment_timing: The timing of the payment
  170. :type payment_timing: str
  171. """
  172. super(Billing, self).__init__()
  173. self["paymentTiming"] = payment_timing
  174. class CmdConfig(dict):
  175. """
  176. This class defines the CmdConfig object.
  177. """
  178. def __init__(self, has_decrease_cmd, dec_cmd_strategy, dec_cmd_data, dec_cmd_timeout, dec_cmd_manual,
  179. has_increase_cmd, inc_cmd_strategy, inc_cmd_data, inc_cmd_timeout, inc_cmd_manual):
  180. """
  181. :param has_decrease_cmd: If has decrease command
  182. :type has_decrease_cmd: bool
  183. :param dec_cmd_strategy: The strategy of the decrease command
  184. :type dec_cmd_strategy: str
  185. :param dec_cmd_data: The data of the decrease command
  186. :type dec_cmd_data: str
  187. :param dec_cmd_timeout: The timeout of the decrease command
  188. :type dec_cmd_timeout: int
  189. :param dec_cmd_manual: If the decrease command is manual
  190. :type dec_cmd_manual: bool
  191. :param has_increase_cmd: If has increase command
  192. :type has_increase_cmd: bool
  193. :param inc_cmd_strategy: The strategy of the increase command
  194. :type inc_cmd_strategy: str
  195. :param inc_cmd_data: The data of the increase command
  196. :type inc_cmd_data: str
  197. :param inc_cmd_timeout: The timeout of the increase command
  198. :type inc_cmd_timeout: int
  199. :param inc_cmd_manual: If the increase command is manual
  200. :type inc_cmd_manual: bool
  201. """
  202. super(CmdConfig, self).__init__()
  203. self["hasDecreaseCmd"] = has_decrease_cmd
  204. self["decCmdStrategy"] = dec_cmd_strategy
  205. self["decCmdData"] = dec_cmd_data
  206. self["decCmdTimeout"] = dec_cmd_timeout
  207. self["decCmdManual"] = dec_cmd_manual
  208. self["hasIncreaseCmd"] = has_increase_cmd
  209. self["incCmdStrategy"] = inc_cmd_strategy
  210. self["incCmdData"] = inc_cmd_data
  211. self["incCmdTimeout"] = inc_cmd_timeout
  212. self["incCmdManual"] = inc_cmd_manual
  213. class BccNameConfig(dict):
  214. """
  215. This class defines the BccNameConfig object.
  216. """
  217. def __init__(self, bcc_name, bcc_hostname):
  218. """
  219. :param bcc_name: The name of the BCC
  220. :type bcc_name: str
  221. :param bcc_hostname: The hostname of the BCC
  222. :type bcc_hostname: str
  223. """
  224. super(BccNameConfig, self).__init__()
  225. self["bccName"] = bcc_name
  226. self["bccHostname"] = bcc_hostname