1 # This utility is designed for use with an OMF Experiment Controller
5 from xmlrpclib import ServerProxy
6 from optparse import OptionParser
8 default_host="www.planet-lab.eu"
11 %prog [--plc plc_hostname] slicename dirname
13 issues a GetSliceSshKeys to the MyPLC instance at <hostname>, and
14 store the keys related to slice <slicename> in <dirname>
15 in a format suitable for use with the OMF Experiment Controller"""
17 parser=OptionParser(usage=usage)
18 parser.add_option ("-p","--plc",action='store',dest='myplc_host',
20 help="the hostname where your myplc is running")
21 (options,args) = parser.parse_args()
25 (slicename, dirname) = args
26 plc_hostname=options.myplc_host
27 plc_url="https://%s/PLCAPI/"%plc_hostname
28 ple=ServerProxy(plc_url,allow_none=True)
29 auth={'AuthMethod':'anonymous'}
30 public_keys=ple.GetSliceSshKeys(auth,slicename)
32 print ("Cannot find any key for slice %s, check slicename ? "%slicename)
34 for (hostname, pubkey) in public_keys.items():
35 filename = os.path.join (dirname, hostname)
36 file = open(filename, "w")
37 filename.write(pubkey)
40 if __name__ == '__main__':