gateway_config.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. instance_config_j_alb = {
  43. # 使用的镜像信息
  44. 'image_id': 'm-bp1e7t7odil9c8kqsm10',
  45. # 设置实例规格
  46. 'instance_type': 'ecs.c6.xlarge',
  47. # 选择的交换机
  48. 'vswitch_id': 'vsw-bp1ssuwxyrt0p17ceeir0',
  49. # 当前VPC类型的安全组
  50. 'security_group_id': 'sg-bp1irhrkr4vfj272hk4y',
  51. # 硬盘的大小,单位:G
  52. 'disk_size': '200',
  53. # 服务器命名
  54. 'instance_name': 'gateway-alb-[1,2]',
  55. # 服务器所在区域
  56. 'zone_id': 'cn-hangzhou-j',
  57. # 磁盘类型:云盘
  58. 'disk_category': 'cloud_essd',
  59. # 密钥
  60. 'key_pair_name': 'stuuudy',
  61. # tag
  62. 'tags': [{"Key": "ecs", "Value": "gateway.prod"}]
  63. }
  64. instance_config_j_clb = {
  65. # 使用的镜像信息
  66. 'image_id': 'm-bp1e7t7odil9c8kqsm10',
  67. # 设置实例规格
  68. 'instance_type': 'ecs.c6.xlarge',
  69. # 选择的交换机
  70. 'vswitch_id': 'vsw-bp1ssuwxyrt0p17ceeir0',
  71. # 当前VPC类型的安全组
  72. 'security_group_id': 'sg-bp1irhrkr4vfj272hk4y',
  73. # 硬盘的大小,单位:G
  74. 'disk_size': '200',
  75. # 服务器命名
  76. 'instance_name': 'gateway-prod-[1,2]',
  77. # 服务器所在区域
  78. 'zone_id': 'cn-hangzhou-j',
  79. # 磁盘类型:云盘
  80. 'disk_category': 'cloud_essd',
  81. # 密钥
  82. 'key_pair_name': 'stuuudy',
  83. # tag
  84. 'tags': [{"Key": "ecs", "Value": "gateway.prod"}]
  85. }
  86. # 服务启动脚本
  87. start_sh_dir = os.path.dirname(os.path.realpath(__file__))
  88. start_sh_filename = 'gateway_start.sh'
  89. with open(file=os.path.join(start_sh_dir, start_sh_filename), mode='r', encoding='utf-8') as rf:
  90. file_content = rf.read()
  91. # logging.info(f"start sh file content: {file_content}")
  92. start_sh = {
  93. 'target_dir': '/home/gateway_server_sh',
  94. 'name': start_sh_filename,
  95. 'content': file_content,
  96. }