longvideoapi_config.py 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. import os
  2. import logging
  3. logging.basicConfig(level=logging.INFO,
  4. format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
  5. datefmt='%a, %d %b %Y %H:%M:%S')
  6. slb_id_list = ["lb-bp1qk9mkvjtundlzz7owm", "lb-bp1pj2v06ladvgftgxcp0", "lb-bp1y63rnrb2e64whryghz", "lb-bp17woaq4vz3gnb8ujzvh"]
  7. server_group_id_list = ["sgp-h79h3lkvua1xs3418y"]
  8. # 修改负载均衡权限
  9. alb_client_params = {
  10. 'access_key_id': 'LTAI5tASD5yEZLeC8ffmNebY',
  11. 'access_key_secret': '1PtsFRdp8viJmI78lEhNZR8MezWZBq',
  12. 'region_id': 'cn-hangzhou'
  13. }
  14. # 购买机器权限
  15. ecs_client_params = {
  16. 'access_key_id': 'LTAI4GBWbFvvXoXsSVBe1o9f',
  17. 'access_key_secret': 'kRAikWitb4kDxaAyBqNrmLmllMEDO3',
  18. 'region_id': 'cn-hangzhou'
  19. }
  20. # 机器配置
  21. instance_config = {
  22. # 使用的镜像信息
  23. 'image_id': 'm-bp12bkuvg20k6ueqmb4v',
  24. # 设置实例规格
  25. 'instance_type': 'ecs.c6.2xlarge',
  26. # 选择的交换机
  27. 'vswitch_id': 'vsw-bp19lpjwtc6j0p0m9mdc2',
  28. # 当前VPC类型的安全组
  29. 'security_group_id': 'sg-bp1irhrkr4vfj272hk4y',
  30. # 硬盘的大小,单位:G
  31. 'disk_size': '200',
  32. # 服务器命名
  33. 'instance_name': 'ESS-vlogapi-[1,2]',
  34. # 服务器所在区域
  35. 'zone_id': 'cn-hangzhou-h',
  36. # 磁盘类型:云盘
  37. 'disk_category': 'cloud_efficiency',
  38. # 密钥
  39. 'key_pair_name': 'stuuudy',
  40. # tag
  41. 'tags': [{"Key": "ecs", "Value": "longvideoapi.prod"}]
  42. }
  43. # 机器配置_hangzhou_i
  44. instance_config_i = {
  45. # 使用的镜像信息
  46. 'image_id': 'm-bp12bkuvg20k6ueqmb4v',
  47. # 设置实例规格
  48. 'instance_type': 'ecs.c6.2xlarge',
  49. # 选择的交换机
  50. 'vswitch_id': 'vsw-bp17c002ovyomzwnhhdhj',
  51. # 当前VPC类型的安全组
  52. 'security_group_id': 'sg-bp1irhrkr4vfj272hk4y',
  53. # 硬盘的大小,单位:G
  54. 'disk_size': '200',
  55. # 服务器命名
  56. 'instance_name': 'ESS-vlogapi-[1,2]',
  57. # 服务器所在区域
  58. 'zone_id': 'cn-hangzhou-i',
  59. # 磁盘类型:云盘
  60. 'disk_category': 'cloud_efficiency',
  61. # 密钥
  62. 'key_pair_name': 'stuuudy',
  63. # tag
  64. 'tags': [{"Key": "ecs", "Value": "longvideoapi.prod"}]
  65. }
  66. # 机器配置_hangzhou_g
  67. instance_config_g = {
  68. # 使用的镜像信息
  69. 'image_id': 'm-bp12bkuvg20k6ueqmb4v',
  70. # 设置实例规格
  71. 'instance_type': 'ecs.c6.2xlarge',
  72. # 选择的交换机
  73. 'vswitch_id': 'vsw-bp10m69sb9ydfa64jdrn3',
  74. # 当前VPC类型的安全组
  75. 'security_group_id': 'sg-bp1irhrkr4vfj272hk4y',
  76. # 硬盘的大小,单位:G
  77. 'disk_size': '200',
  78. # 服务器命名
  79. 'instance_name': 'ESS-vlogapi-[1,2]',
  80. # 服务器所在区域
  81. 'zone_id': 'cn-hangzhou-g',
  82. # 磁盘类型:云盘
  83. 'disk_category': 'cloud_efficiency',
  84. # 密钥
  85. 'key_pair_name': 'stuuudy',
  86. # tag
  87. 'tags': [{"Key": "ecs", "Value": "longvideoapi.prod"}]
  88. }
  89. # 机器配置_hangzhou_j
  90. instance_config_j = {
  91. # 使用的镜像信息
  92. 'image_id': 'm-bp12bkuvg20k6ueqmb4v',
  93. # 设置实例规格
  94. 'instance_type': 'ecs.c6.2xlarge',
  95. # 选择的交换机
  96. 'vswitch_id': 'vsw-bp1ssuwxyrt0p17ceeir0',
  97. # 当前VPC类型的安全组
  98. 'security_group_id': 'sg-bp1irhrkr4vfj272hk4y',
  99. # 硬盘的大小,单位:G
  100. 'disk_size': '200',
  101. # 服务器命名
  102. 'instance_name': 'ESS-vlogapi-[1,2]',
  103. # 服务器所在区域
  104. 'zone_id': 'cn-hangzhou-j',
  105. # 磁盘类型:云盘
  106. 'disk_category': 'cloud_efficiency',
  107. # 密钥
  108. 'key_pair_name': 'stuuudy',
  109. # tag
  110. 'tags': [{"Key": "ecs", "Value": "longvideoapi.prod"}]
  111. }
  112. # 机器配置_hangzhou_k
  113. instance_config_k = {
  114. # 使用的镜像信息
  115. 'image_id': 'm-bp12bkuvg20k6ueqmb4v',
  116. # 设置实例规格
  117. 'instance_type': 'ecs.c6.2xlarge',
  118. # 选择的交换机
  119. 'vswitch_id': 'vsw-bp14e4xu6uzte9nyn6nvr',
  120. # 当前VPC类型的安全组
  121. 'security_group_id': 'sg-bp1irhrkr4vfj272hk4y',
  122. # 硬盘的大小,单位:G
  123. 'disk_size': '200',
  124. # 服务器命名
  125. 'instance_name': 'ESS-longvideoapi-alb-[1,2]',
  126. # 服务器所在区域
  127. 'zone_id': 'cn-hangzhou-k',
  128. # 磁盘类型:云盘
  129. 'disk_category': 'cloud_efficiency',
  130. # 密钥
  131. 'key_pair_name': 'stuuudy',
  132. # tag
  133. 'tags': [{"Key": "ecs", "Value": "longvideoapi.prod"}]
  134. }
  135. # 机器配置_hangzhou_k alb
  136. instance_config_k_alb = {
  137. # 使用的镜像信息
  138. 'image_id': 'm-bp12bkuvg20k6ueqmb4v',
  139. # 设置实例规格
  140. 'instance_type': 'ecs.c6.2xlarge',
  141. # 选择的交换机
  142. 'vswitch_id': 'vsw-bp14e4xu6uzte9nyn6nvr',
  143. # 当前VPC类型的安全组
  144. 'security_group_id': 'sg-bp1irhrkr4vfj272hk4y',
  145. # 硬盘的大小,单位:G
  146. 'disk_size': '200',
  147. # 服务器命名
  148. 'instance_name': 'ESS-vlogapi-alb-[1,2]',
  149. # 服务器所在区域
  150. 'zone_id': 'cn-hangzhou-k',
  151. # 磁盘类型:云盘
  152. 'disk_category': 'cloud_efficiency',
  153. # 密钥
  154. 'key_pair_name': 'stuuudy',
  155. # tag
  156. 'tags': [{"Key": "ecs", "Value": "longvideoapi.prod"}]
  157. }
  158. # 服务启动脚本
  159. start_sh_dir = os.path.dirname(os.path.realpath(__file__))
  160. start_sh_filename = 'longvideo_start.sh'
  161. with open(file=os.path.join(start_sh_dir, start_sh_filename), mode='r', encoding='utf-8') as rf:
  162. file_content = rf.read()
  163. logging.info(f"start sh file content: {file_content}")
  164. start_sh = {
  165. 'target_dir': '/home/piaoquan_server_sh',
  166. 'name': start_sh_filename,
  167. 'content': file_content,
  168. }