From: Thierry Parmentelat Date: Thu, 18 Dec 2008 20:50:46 +0000 (+0000) Subject: an example using regular python X-Git-Tag: PLCAPI-4.3-3~16 X-Git-Url: http://git.onelab.eu/?p=plcapi.git;a=commitdiff_plain;h=c063f62b38ba4bdb7fbd479d73b7e49b365dc0ac an example using regular python --- diff --git a/doc/PLCAPI.xml.in b/doc/PLCAPI.xml.in index b3777a0..2f04d35 100644 --- a/doc/PLCAPI.xml.in +++ b/doc/PLCAPI.xml.in @@ -419,6 +419,49 @@ nodes = GetNodes([121], ['node_id', 'hostname']) nodes = plc.GetNodes([121], ['node_id', 'hostname']) + +
+ Using regular python + + It is also possible to write simple regular-python scripts, + as illustrated in the example below. The only difference is that + all API calls need to be passed a first argument for + athenticating: + + +#!/usr/bin/env python + +import xmlrpclib + +plc_host='www.planet-lab.eu' +login='thierry.parmentelat@sophia.inria.fr' +password='xxxxxxxx' + +slice_name='inria_heartbeat' + +auth = { 'AuthMethod' : 'password', + 'Username' : login, + 'AuthString' : password, +} + +api_url="https://%s:443/PLCAPI/"%plc_host + +plc_api = xmlrpclib.ServerProxy(api_url,allow_none=True) + +# the slice's node ids +node_ids = plc_api.GetSlices(auth,slice_name,['node_ids'])[0]['node_ids'] + +# get hostname for these nodes +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'] +f.close() + +
+