From: Thierry Parmentelat Date: Thu, 15 Nov 2012 18:27:04 +0000 (+0100) Subject: convenience script for coupling with the OMF Experiment Controller X-Git-Tag: myplc-5.1-5~10 X-Git-Url: http://git.onelab.eu/?p=myplc.git;a=commitdiff_plain;h=e143940d896bf696a949dbf70f7d96327acf5f62 convenience script for coupling with the OMF Experiment Controller --- diff --git a/user-scripts/slice_ssh_keys.py b/user-scripts/slice_ssh_keys.py new file mode 100755 index 0000000..a7623ab --- /dev/null +++ b/user-scripts/slice_ssh_keys.py @@ -0,0 +1,43 @@ +# This utility is designed for use with an OMF Experiment Controller +# +import sys +import os.path +from xmlrpclib import ServerProxy +from optparse import OptionParser + +default_host="www.planet-lab.eu" +def main (): + usage="""Usage: + %prog [--plc plc_hostname] slicename dirname +Purpose: + issues a GetSliceSshKeys to the MyPLC instance at , and + store the keys related to slice in + in a format suitable for use with the OMF Experiment Controller""" + + parser=OptionParser(usage=usage) + parser.add_option ("-p","--plc",action='store',dest='myplc_host', + default=default_host, + help="the hostname where your myplc is running") + (options,args) = parser.parse_args() + if len(args) != 2: + parser.print_help() + sys.exit(1) + (slicename, dirname) = args + plc_hostname=options.myplc_host + plc_url="https://%s/PLCAPI/"%plc_hostname + ple=ServerProxy(plc_url,allow_none=True) + auth={'AuthMethod':'anonymous'} + public_keys=ple.GetSliceSshKeys(auth,slicename) + if not public_keys: + print ("Cannot find any key for slice %s, check slicename ? "%slicename) + return 1 + for (hostname, pubkey) in public_keys.items(): + filename = os.path.join (dirname, hostname) + file = open(filename, "w") + filename.write(pubkey) + filename.close() + +if __name__ == '__main__': + sys.exit(main()) + +