-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathip_array.py
More file actions
70 lines (57 loc) · 1.83 KB
/
ip_array.py
File metadata and controls
70 lines (57 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/python2.7
import json
import os
import commands
from sys import argv
import load_xml as lx
import sys
def load_str(finename):
f = open(finename, "r")
str = f.read()
f.close()
return str
def load_filters():
file_json_path = "service.json"
str = load_str(file_json_path)
filters = json.loads(str)
return filters
def echo_random(arg):
os.system(shelldir + "/echo_color random \"" + arg + "\"")
def echo_diff(arg):
os.system(shelldir + "/echo_color diff \"" + arg + "\"")
def service_save_path(bugnum):
date = commands.getoutput("date \"+%Y%m%d%H%M\"")
path = "/mnt/log/" + bugnum + "/" + date + "/"
return path
def ok_path(service_path, service_name, ip):
return service_path + "/" + service_name + "/" + ip + "/ok"
def check_remove_waitlist(waitlist, service_path):
for array in waitlist:
service_name = array[0]
ip = array[1]
if( os.path.exists(ok_path(service_path, service_name, ip))):
waitlist.remove(array)
echo_diff("-----------" + service_name + " " + ip + "------ok")
break
return waitlist
if __name__ == '__main__':
if (len(argv) < 3): help();exit(1)
projectdir = argv[1]
xml_path = argv[2]
out_service_name = argv[3]
name_filters=load_filters()
in_service_name = name_filters[out_service_name]
# print(in_service_name,sys.stderr)
shelldir = projectdir + "/tool/shell"
# print projectdir
# print xml_path
# print out_service_name
nodes, services, smoke = lx.load_xml(xml_path)
service_names = []
res = []
for service_name, service in services.items():
if(in_service_name == service_name):
for nodename, nodeinfo in service["dest"].items():
ip = nodeinfo["node"]["ip"]
res.append(ip)
print json.dumps(res)