gateway_config.py 2.5 KB

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