-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-client.py
More file actions
100 lines (94 loc) · 3.08 KB
/
Copy pathtest-client.py
File metadata and controls
100 lines (94 loc) · 3.08 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import pdb
from keystoneauth1.identity import v3
from keystoneauth1 import session
from novaclient import client
from neutronclient.v2_0 import client as neutron_client
def createJSONResponse(*argv):
try:
argv[3]
except Exception:
button = False
else:
button = True
try:
argv[4]
except Exception:
callSet = False
else:
callSet = True
response = "{\"message\": \""+argv[2]+"\",\"type\": \""+argv[0]+"\""
l = []
if argv[1] is not None:
response = response + ",\"list\":["
for a in argv[1]:
temp = str(a).split(":")[1].strip()[:-1]
temp1 = "{\"value\": \""+temp+"\"},"
response = response + temp1
response = response[:-1] + "]"
response = response + ",\"button\":\""+str(button)+"\""+ ",\"callSet\":\""+str(callSet)+"\""
response = response+ "}"
return "angular.callbacks._0("+response+")"
def cre22ateJSONResponse(*argv):
try:
argv[3]
except Exception:
button = False
else:
button = True
response = "{\"message\": \""+argv[2]+"\",\"type\": \""+argv[0]+"\""
l = []
if argv[1] is not None:
response = response + ",\"list\":["
for a in argv[1]:
temp = str(a).split(":")[1].strip()[:-1]
temp1 = "{\"value\": \""+temp+"\"},"
response = response + temp1
response = response[:-1] + "]"
response = response + ",\"button\":\""+str(button)+"\""
response = response+ "}"
return "angular.callbacks._0("+response+")"
def createJSONResponse1(*argv):
try:
argv[3]
except Exception:
button = False
else:
button = True
response = "{\"message\": \""+argv[2]+"\",\"type\": \""+argv[0]+"\""
l = []
if argv[1] is not None:
response = response + ",\"list\":["
for a in argv[1]:
temp = str(a).split(":")[1].strip()[:-1]
temp1 = "{\"value\": \""+temp+"\"},"
response = response + temp1
response = response[:-1] + "]"
response = response + ",\"button\":\""+str(button)+"\""
response = response+ "}"
return response
auth = v3.Password(auth_url='http://192.168.0.12:5000/v3',
username='admin',
password='1',
project_name='admin',
user_domain_id='default',
project_domain_id='default')
sess = session.Session(auth=auth)
nova = client.Client("2.1", session=sess)
#nova.servers.create("nish",flavor="m1.tiny")
neutron = neutron_client.Client(session=sess)
#response = createJSONResponse("AZ",nova.availability_zones.list(),"msg")
#print(response)
list = nova.flavors.list()
network_list = neutron.list_networks()
netlist = []
temp_list = network_list['networks']
for i in temp_list:
for k, v in i.iteritems():
if str(k)=='name':
k1 = '<'+str(k)
v1 = str(v)+'>'
w = k1+':'+v1
netlist.append(w)
print netlist
print nova.availability_zones.list()
print createJSONResponse("",list,"Plain message")