gateway_config.py 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. # alb后端服务器_调试使用组
  7. # server_group_id_list = ["sgp-ec4gopoclruofsfmxu"]
  8. # clb 测试环境_临时调试使用
  9. # clb_id_list = ["lb-bp1i49h7ncw2c9nl3kp6u"]
  10. # gateway-alb-ecs组-生产环境
  11. server_group_id_list = ["sgp-l2k0p33e470vfmj538"]
  12. # gateway clb 生产环境
  13. clb_id_list = ["lb-bp1mfk1gmd47twfh6bgwv", "lb-bp1jtzhp9krunyv3mim2q"]
  14. apps = 'piaoquan-gateway'
  15. repository = 'registry-vpc.cn-hangzhou.aliyuncs.com/stuuudy/{}'
  16. registry = 'registry-vpc.cn-hangzhou.aliyuncs.com/stuuudy/{}:{}'
  17. # 后端服务器使用的端口
  18. port = "9000"
  19. # 修改负载均衡权限
  20. clb_client_params = {
  21. 'access_key_id': 'LTAIuPbTPL3LDDKN',
  22. 'access_key_secret': 'ORcNedKwWuwVtcq4IRFtUDZgS0b1le',
  23. 'region_id': 'cn-hangzhou'
  24. }
  25. alb_client_params = {
  26. 'access_key_id': 'LTAI5tASD5yEZLeC8ffmNebY',
  27. 'access_key_secret': '1PtsFRdp8viJmI78lEhNZR8MezWZBq',
  28. 'endpoint': 'alb-vpc.cn-hangzhou.aliyuncs.com',
  29. 'region_id': 'cn-hangzhou'
  30. }
  31. # 购买机器权限
  32. ecs_client_params = {
  33. 'access_key_id': 'LTAI4GBWbFvvXoXsSVBe1o9f',
  34. 'access_key_secret': 'kRAikWitb4kDxaAyBqNrmLmllMEDO3',
  35. 'region_id': 'cn-hangzhou'
  36. }
  37. docker_config = {
  38. 'username': 'stuuudys',
  39. 'password': 'Qingqu@2019',
  40. 'registry': 'registry-vpc.cn-hangzhou.aliyuncs.com'
  41. }
  42. # # 机器配置_hangzhou_j
  43. # instance_config_j = {
  44. # # 使用的镜像信息
  45. # 'image_id': 'm-bp1e7t7odil9c8kqsm10',
  46. # # 设置实例规格
  47. # 'instance_type': 'ecs.c6.xlarge',
  48. # # 选择的交换机
  49. # 'vswitch_id': 'vsw-bp1ssuwxyrt0p17ceeir0',
  50. # # 当前VPC类型的安全组
  51. # 'security_group_id': 'sg-bp1irhrkr4vfj272hk4y',
  52. # # 硬盘的大小,单位:G
  53. # 'disk_size': '200',
  54. # # 服务器命名
  55. # 'instance_name': 'gateway-alb-[1,2]',
  56. # # 服务器所在区域
  57. # 'zone_id': 'cn-hangzhou-j',
  58. # # 磁盘类型:云盘
  59. # 'disk_category': 'cloud_essd',
  60. # # 密钥
  61. # 'key_pair_name': 'stuuudy',
  62. # # tag
  63. # 'tags': [{"Key": "ecs", "Value": "gateway.prod"}]
  64. # }
  65. instance_config_j_alb = {
  66. # 使用的镜像信息
  67. 'image_id': 'm-bp1e7t7odil9c8kqsm10',
  68. # 设置实例规格
  69. 'instance_type': 'ecs.c6.xlarge',
  70. # 选择的交换机
  71. 'vswitch_id': 'vsw-bp1ssuwxyrt0p17ceeir0',
  72. # 当前VPC类型的安全组
  73. 'security_group_id': 'sg-bp1irhrkr4vfj272hk4y',
  74. # 硬盘的大小,单位:G
  75. 'disk_size': '200',
  76. # 服务器命名
  77. 'instance_name': 'gateway-alb-[1,2]',
  78. # 服务器所在区域
  79. 'zone_id': 'cn-hangzhou-j',
  80. # 磁盘类型:云盘
  81. 'disk_category': 'cloud_essd',
  82. # 密钥
  83. 'key_pair_name': 'stuuudy',
  84. # tag
  85. 'tags': [{"Key": "ecs", "Value": "gateway.prod"}]
  86. }
  87. instance_config_j_clb = {
  88. # 使用的镜像信息
  89. 'image_id': 'm-bp1e7t7odil9c8kqsm10',
  90. # 设置实例规格
  91. 'instance_type': 'ecs.c6.xlarge',
  92. # 选择的交换机
  93. 'vswitch_id': 'vsw-bp1ssuwxyrt0p17ceeir0',
  94. # 当前VPC类型的安全组
  95. 'security_group_id': 'sg-bp1irhrkr4vfj272hk4y',
  96. # 硬盘的大小,单位:G
  97. 'disk_size': '200',
  98. # 服务器命名
  99. 'instance_name': 'gateway-prod-[1,2]',
  100. # 服务器所在区域
  101. 'zone_id': 'cn-hangzhou-j',
  102. # 磁盘类型:云盘
  103. 'disk_category': 'cloud_essd',
  104. # 密钥
  105. 'key_pair_name': 'stuuudy',
  106. # tag
  107. 'tags': [{"Key": "ecs", "Value": "gateway.prod"}]
  108. }
  109. # 服务启动脚本
  110. start_sh_dir = os.path.dirname(os.path.realpath(__file__))
  111. start_sh_filename = 'gateway_start.sh'
  112. with open(file=os.path.join(start_sh_dir, start_sh_filename), mode='r', encoding='utf-8') as rf:
  113. file_content = rf.read()
  114. logging.info(f"start sh file content: {file_content}")
  115. start_sh = {
  116. 'target_dir': '/home/gateway_server_sh',
  117. 'name': start_sh_filename,
  118. 'content': file_content,
  119. }