| Line | |
|---|
| 1 | #!/usr/bin/python |
|---|
| 2 | |
|---|
| 3 | import xmlrpclib |
|---|
| 4 | |
|---|
| 5 | s = xmlrpclib.Server('https://www.planet-lab.org/PLCAPI/') |
|---|
| 6 | auth = {"AuthMethod":"password", "AuthString": "4d792a5b27530aa53a3cb4e1a1d03d547d9b0433", "Username": "klai@hp.com", "Role": "pi"} |
|---|
| 7 | |
|---|
| 8 | print "Checking authentication." |
|---|
| 9 | s.AdmAuthCheck(auth) |
|---|
| 10 | |
|---|
| 11 | print "Getting node list." |
|---|
| 12 | all_nodes = s.AdmGetNodes(auth) |
|---|
| 13 | print "%s nodes in list" % (len(all_nodes),) |
|---|
| 14 | |
|---|
| 15 | print "Getting bound nodes" |
|---|
| 16 | slice_name = "hplabs_tycoon" |
|---|
| 17 | l = s.SliceNodesList(auth, slice_name) |
|---|
| 18 | |
|---|
| 19 | bound_nodes = dict(zip(l, (True,) * len(l))) |
|---|
| 20 | for node in all_nodes: |
|---|
| 21 | if node['hostname'] in bound_nodes: |
|---|
| 22 | continue |
|---|
| 23 | print "Adding %s" % (node['hostname'],) |
|---|
| 24 | s.SliceNodesAdd(auth, slice_name, [node['hostname']]) |
|---|