...
|
...
|
@@ -13,6 +13,7 @@ from jinja2 import Environment, FileSystemLoader |
|
|
import collections
|
|
|
import time
|
|
|
import sys
|
|
|
import get_iplist
|
|
|
|
|
|
# clone deploy project to local
|
|
|
HOME = os.path.expanduser("~")
|
...
|
...
|
@@ -26,7 +27,7 @@ call("git clone --recursive git@git.yoho.cn:yohoops/auto_deploy.git %s" % PATH |
|
|
|
|
|
|
|
|
# get iptables info from git files.
|
|
|
azs_mappings = {"qcloud": "az1", "aws": "aws", "t6": "t6"}
|
|
|
azs_mappings = {"qcloud": "az1", "aws": "aws", "t6": "t6", "containers": "containers"}
|
|
|
host_group = { "nginx": "java-nginx",
|
|
|
"yoho_gateway": "java-gateway",
|
|
|
"yoho_users": "java-users",
|
...
|
...
|
@@ -62,26 +63,43 @@ host_group = { "nginx": "java-nginx", |
|
|
"yoho_reviewed": "java-review",
|
|
|
"yoho_message_controller": "java-messagecontroller"
|
|
|
}
|
|
|
containers_host_group = { "media-containers": "media-containers",
|
|
|
"web-containers": "web-containers",
|
|
|
"yoho-java-container": "yoho-java-container",
|
|
|
"yoho-ops-container": "yoho-ops-container"
|
|
|
}
|
|
|
# all available zone groups
|
|
|
all_groups = {}
|
|
|
ClusterIds = {"yoho-java-container": "cls-rzb97zht","yoho-ops-container": "cls-gscif1o5","media-containers": "cls-qzkxrhg7","web-containers": "cls-ro6kl3cp"}
|
|
|
for _az in azs_mappings.keys():
|
|
|
groups = {}
|
|
|
all_groups[azs_mappings[_az]] = groups
|
|
|
file = open(os.path.join(PATH, "scripts/iptable/", _az, "app-iptable.sh"), 'r')
|
|
|
for line in file:
|
|
|
for deploy_prj_name in host_group.keys():
|
|
|
if line.strip().startswith(deploy_prj_name + "_" + _az):
|
|
|
g_hosts = []
|
|
|
groups[host_group[deploy_prj_name]] = g_hosts
|
|
|
i_1 = line.index("(")
|
|
|
i_2 = line.index(")")
|
|
|
sub = line[i_1 + 1 : i_2]
|
|
|
for user_ip in sub.split("master@"):
|
|
|
if user_ip.strip() != '':
|
|
|
g_hosts.append(user_ip.strip())
|
|
|
|
|
|
|
|
|
file.close()
|
|
|
if _az == "containers":
|
|
|
for line in ClusterIds.keys():
|
|
|
for deploy_prj_name in containers_host_group.keys():
|
|
|
if line == deploy_prj_name:
|
|
|
g_hosts = []
|
|
|
groups[containers_host_group[deploy_prj_name]] = g_hosts
|
|
|
result = get_iplist.ip_inqure(ClusterIds[line])
|
|
|
ip_s = result['data']['data']['nodes']
|
|
|
for ip in ip_s:
|
|
|
g_hosts.append(ip['lanIp'].strip())
|
|
|
else:
|
|
|
file = open(os.path.join(PATH, "scripts/iptable/", _az, "app-iptable.sh"), 'r')
|
|
|
for line in file:
|
|
|
for deploy_prj_name in host_group.keys():
|
|
|
if line.strip().startswith(deploy_prj_name + "_" + _az):
|
|
|
g_hosts = []
|
|
|
groups[host_group[deploy_prj_name]] = g_hosts
|
|
|
i_1 = line.index("(")
|
|
|
i_2 = line.index(")")
|
|
|
sub = line[i_1 + 1 : i_2]
|
|
|
for user_ip in sub.split("master@"):
|
|
|
if user_ip.strip() != '':
|
|
|
g_hosts.append(user_ip.strip())
|
|
|
|
|
|
|
|
|
file.close()
|
|
|
|
|
|
print("get all inventory info success. \n")
|
|
|
print(all_groups)
|
...
|
...
|
|