gateway_config.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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': 'ESS-gateway-[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. # 服务启动脚本
  66. start_sh_dir = os.path.dirname(os.path.realpath(__file__))
  67. start_sh_filename = 'gateway_start.sh'
  68. with open(file=os.path.join(start_sh_dir, start_sh_filename), mode='r', encoding='utf-8') as rf:
  69. file_content = rf.read()
  70. # logging.info(f"start sh file content: {file_content}")
  71. start_sh = {
  72. 'target_dir': '/home/gateway_server_sh',
  73. 'name': start_sh_filename,
  74. 'content': file_content,
  75. }