FORGE: Added including script
[myslice.git] / forge / script / PlcApi / getSlices.py
1 #!/usr/bin/python
2
3 import xmlrpclib
4 import Auth
5 import sys
6
7 slice_pref='upmc_'
8
9 plc_host='www.planet-lab.eu'
10 api_url="https://%s:443/PLCAPI/"%plc_host
11
12 plc_api= xmlrpclib.ServerProxy(api_url, allow_none=True)
13
14 sliceName = slice_pref+raw_input("Give me the name of the slice : ")
15
16 sliceWanted = None
17 slices = plc_api.GetSlices(Auth.auth, sliceName, ['creator_person_id', 'name', 'max_nodes', 'node_ids', 'person_ids', 'slice_id'])
18
19 if len(slices) > 0:
20         for slice_i in slices:
21                 print slice_i['name']
22         sliceWanted = slices[0]
23
24 if sliceWanted == None:
25         print "The slice "+sliceName+" doesn't exist"
26         sys.exit(2)
27 persons = plc_api.GetPersons(Auth.auth, sliceWanted['person_ids'], ['first_name', 'email'])
28 nodes = plc_api.GetNodes(Auth.auth, sliceWanted['node_ids'], ['hostname', 'site_id', 'node_id'])
29
30 tags = plc_api.GetSliceTags(Auth.auth, {'slice_id': sliceWanted['slice_id']}, ['description', 'tagname', 'value', 'slice_tag_id'])
31
32 creator = plc_api.GetPersons(Auth.auth, sliceWanted['creator_person_id'], ['first_name', 'email'])
33
34
35 for person in persons:
36         print person
37
38 if creator not in persons:
39         print "\tCreator"
40         print "\t\t"+str(creator)
41 else:
42         print "\tCreator is in user list"
43
44 print sliceWanted
45 for node in nodes:
46         print "\t"+str(node)
47         pass
48 print "Tag list"
49 for tag in tags:
50         #print "\t"+str(tag)
51         pass