<programlisting>
>>> tagnames=['arch','fcdistro','hrn','hmac','exempt_node_until']
>>> for tt in GetTagTypes(tagnames,['tagname','category']):
->>> ... print "tagname=%-18s category=%s"%(tt['tagname'], tt['category'])
+>>> ... print("tagname=%-18s category=%s"%(tt['tagname'], tt['category']))
tagname=hrn category=node/sfa
tagname=hmac category=slice/auth
tagname=exempt_node_until category=node/myops
>>> AddNodeGroup('betanodes','deployment','beta')
22
### checking contents (no node has 'deployment' set to either 'alpha' or 'beta' yet)
->>> for ng in GetNodeGroups(['alphanodes','betanodes'],['groupname','node_ids']): print ng
+>>> for ng in GetNodeGroups(['alphanodes','betanodes'],['groupname','node_ids']): print(ng)
{'groupname': u'alphanodes', 'node_ids': []}
{'groupname': u'betanodes', 'node_ids': []}
### displaying node ids
->>> for n in GetNodes({'hostname':'*.inria.fr'},['hostname','node_id']): print n
+>>> for n in GetNodes({'hostname':'*.inria.fr'},['hostname','node_id']): print(n)
{'hostname': u'vnode01.inria.fr', 'node_id': 1}
{'hostname': u'vnode02.inria.fr', 'node_id': 2}
### setting 'deployment' for these two nodes
>>> SetNodeDeployment('vnode01.inria.fr','alpha')
->>> for ng in GetNodeGroups(['alphanodes','betanodes'],['groupname','node_ids']): print ng
+>>> for ng in GetNodeGroups(['alphanodes','betanodes'],['groupname','node_ids']): print(ng)
{'groupname': u'alphanodes', 'node_ids': [1]}
{'groupname': u'betanodes', 'node_ids': []}
>>> SetNodeDeployment('vnode02.inria.fr','beta')
### checking contents again
->>> for ng in GetNodeGroups(['alphanodes','betanodes'],['groupname','node_ids']): print ng
+>>> for ng in GetNodeGroups(['alphanodes','betanodes'],['groupname','node_ids']): print(ng)
{'groupname': u'alphanodes', 'node_ids': [1]}
{'groupname': u'betanodes', 'node_ids': [2]}
</programlisting>
the <function>PLC.Shell</function> module:</para>
<programlisting>
-#!/usr/bin/python
+#!/usr/bin/python3
import sys
the name of all the hosts attached to a given slice.</para>
<programlisting>
-#!/usr/bin/env python
+#!/usr/bin/env python3
-import xmlrpclib
+import xmlrpc.client
plc_host='www.planet-lab.eu'
api_url="https://%s:443/PLCAPI/"%plc_host
-plc_api = xmlrpclib.ServerProxy(api_url,allow_none=True)
+plc_api = xmlrpc.client.ServerProxy(api_url,allow_none=True)
# the slice's node ids
node_ids = plc_api.GetSlices(auth,slice_name,['node_ids'])[0]['node_ids']
slice_nodes = plc_api.GetNodes(auth,node_ids,['hostname'])
# store in a file
-f=open('mynodes.txt','w')
-for node in slice_nodes:
- print >>f,node['hostname']
+with ('mynodes.txt','a') as f:
+ for node in slice_nodes:
+ f.write(node['hostname'] + "\n")
f.close()
</programlisting>
</section>