longvideo_config.py 5.3 KB

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