[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25719 - gnunet-planetlab/gplmt/scripts
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25719 - gnunet-planetlab/gplmt/scripts |
Date: |
Tue, 8 Jan 2013 18:25:08 +0100 |
Author: wachs
Date: 2013-01-08 18:25:08 +0100 (Tue, 08 Jan 2013)
New Revision: 25719
Added:
gnunet-planetlab/gplmt/scripts/gplmt-api.py
Removed:
gnunet-planetlab/gplmt/scripts/getallnodes.py
gnunet-planetlab/gplmt/scripts/getmynodes.py
Log:
- merge and rename
Deleted: gnunet-planetlab/gplmt/scripts/getallnodes.py
===================================================================
--- gnunet-planetlab/gplmt/scripts/getallnodes.py 2013-01-08 17:15:12 UTC
(rev 25718)
+++ gnunet-planetlab/gplmt/scripts/getallnodes.py 2013-01-08 17:25:08 UTC
(rev 25719)
@@ -1,56 +0,0 @@
-#!/usr/bin/python
-
-# List all available nodes in state "booted" to slice
-
-
-import sys, os, urllib, xmlrpclib, socket
-
-user = ''
-password = ''
-slice = ''
-
-arg = sys.argv
-size = len(arg)
-if (len(arg) < 6):
- print 'usage: -u <username> -p <password> -s <slice>'
- exit()
-
-if (arg[1] == '-u'):
- user = arg[2]
-if (arg[3] == '-p'):
- password = arg[4]
-if (arg[5] == '-s'):
- slice = arg[6]
-
-
-# PlanetLab Europe
-api_url = "https://www.planet-lab.eu/PLCAPI/"
-# Planetlab Central
-#api_url = https://www.planet-lab.org/PLCAPI/
-
-server = xmlrpclib.ServerProxy(api_url)
-
-# the auth struct
-auth = {}
-auth['Username'] = user
-auth['AuthString'] = password
-auth['AuthMethod'] = "password"
-
-# request all sites on PL
-try:
- sites = server.GetSites(auth,{},['site_id','name','latitude','longitude'])
- nsites = len(sites)
-except Exception as e:
- print "Error while retrieving site list: " + str(e)
-
-
-# request all nodes on PL
-filter_dict = {"boot_state":"boot"}
-try:
- nodes =
server.GetNodes(auth,filter_dict,['site_id','node_id','hostname','boot_state'])
- nnodes = len(nodes)
- for node in nodes:
- print node.get('hostname')
-except Exception as e:
- print "Error while retrieving node list: " + str(e)
-
\ No newline at end of file
Deleted: gnunet-planetlab/gplmt/scripts/getmynodes.py
===================================================================
--- gnunet-planetlab/gplmt/scripts/getmynodes.py 2013-01-08 17:15:12 UTC
(rev 25718)
+++ gnunet-planetlab/gplmt/scripts/getmynodes.py 2013-01-08 17:25:08 UTC
(rev 25719)
@@ -1,158 +0,0 @@
-#!/usr/bin/python
-import sys, xmlrpclib, getopt, getpass
-
-
-def usage():
- print "GNUnet PlanetLab deployment and automation toolset\n\
-Arguments mandatory for long options are also mandatory for short options.\n\
- -c, --config= configuration file\n\
- -p, --user= Planetlab username\n\
- -p. --password= Planetlab password\n\
- -s, --slice= Planetlab slice\n\
- -h, --help print this help\n\
- -o, --operation= all,my\n\
-Report bugs to address@hidden \n\
-GNUnet home page: http://www.gnu.org/software/gnunet/ \n\
-General help using GNU software: http://www.gnu.org/gethelp/"
-
-# configuration
-pl_user = None
-pl_password = None
-pl_slicename = None
-cfgfile = None
-op = None
-
-def parse_arg ():
- global cfgfile
- global pl_user
- global pl_password
- global pl_slicename
- global op
- try:
- opts, args = getopt.getopt(sys.argv[1:], "hc:u:p:s:o:", ["help",
"config", "pl_user=", "pl_password=", "slice=", "operation="])
- except getopt.GetoptError, err:
- # print help information and exit:
- print str(err) # will print something like "option -a not recognized"
- usage()
- sys.exit(2)
- for o, a in opts:
- if o in ("-h", "--help"):
- usage()
- sys.exit()
- elif o in ("-u", "--pl_user"):
- pl_user = a
- elif o in ("-p", "--pl_password"):
- pl_password = a
- elif o in ("-c", "--config"):
- cfgfile = a
- elif o in ("-s", "--slice"):
- pl_slicename = a
- elif o in ("-o", "--operation"):
- if (a == "all"):
- op = "all"
- elif (a == "my"):
- op = "my"
- else:
- usage()
- sys.exit()
- else:
- assert False, "unhandled option"
-
-def update_conf (configuration):
- if (None != pl_user):
- configuration.pl_user = pl_user
- if (None != pl_password):
- configuration.pl_password = pl_password
- if (None != pl_slicename):
- configuration.pl_slicename = pl_slicename
- if (None != pl_password):
- configuration.pl_password = pl_password
-
-def list_my_nodes (configuration):
- # PlanetLab XML RPC server
- server = xmlrpclib.ServerProxy(configuration.pl_api_url)
- # PlanetLab auth struct
- auth = {}
- auth['Username'] = configuration.pl_username
- auth['AuthString'] = configuration.pl_password
- auth['AuthMethod'] = "password"
- # PlanetLab Slice data
- slice_data = {}
- slice_data['name'] = configuration.pl_slicename
-
- # request nodes assigned to slice
- try:
- node_ids = server.GetSlices(auth, [slice_data['name']],
['node_ids'])[0]['node_ids']
- node_hostnames = [node['hostname'] for node in server.GetNodes(auth,
node_ids, ['hostname'])]
-
- for node in node_hostnames:
- print node
- except Exception as e:
- print "Error while retrieving node list: " + str(e)
-
-def list_all_nodes (configuration):
- # PlanetLab XML RPC server
- server = xmlrpclib.ServerProxy(configuration.pl_api_url)
- # PlanetLab auth struct
- auth = {}
- auth['Username'] = configuration.pl_username
- auth['AuthString'] = configuration.pl_password
- auth['AuthMethod'] = "password"
- # PlanetLab Slice data
- slice_data = {}
- slice_data['name'] = configuration.pl_slicename
-
- # request all sites on PL
- try:
- sites =
server.GetSites(auth,{},['site_id','name','latitude','longitude'])
- nsites = len(sites)
- except Exception as e:
- print "Error while retrieving site list: " + str(e)
- # request all nodes on PL
- filter_dict = {"boot_state":"boot"}
- try:
- nodes =
server.GetNodes(auth,filter_dict,['site_id','node_id','hostname','boot_state'])
- nnodes = len(nodes)
- for node in nodes:
- print node.get('hostname')
- except Exception as e:
- print "Error while retrieving node list: " + str(e)
-
-def main():
- global cfgfile
- global op
- #import gplmt
- import gplmt.Configuration as Configuration
- import gplmt.Util as Util
-
- logger = Util.Logger (False)
- # Parse command line arguments
- parse_arg ()
- configuration = Configuration.Configuration (cfgfile, logger)
- configuration.load ()
- update_conf (configuration)
-
- if ((configuration.pl_username == "") or
- (configuration.pl_slicename == "")):
- #usage ()
- sys.exit (2)
- if (configuration.pl_api_url == ""):
- # PlanetLab Europe
- configuration.pl_api_url = "https://www.planet-lab.eu/PLCAPI/"
- if (configuration.pl_password == ""):
- print "Please enter PlanetLab password:"
- configuration.pl_password = getpass.getpass()
-
- if (op == "all"):
- list_all_nodes (configuration)
- elif (op == "my"):
- list_my_nodes (configuration)
- else:
- usage()
- sys.exit()
-
-
-if (__name__ == "__main__"):
- # Modify search path to include gplmt
- sys.path.append('../')
- main ()
Copied: gnunet-planetlab/gplmt/scripts/gplmt-api.py (from rev 25718,
gnunet-planetlab/gplmt/scripts/getmynodes.py)
===================================================================
--- gnunet-planetlab/gplmt/scripts/gplmt-api.py (rev 0)
+++ gnunet-planetlab/gplmt/scripts/gplmt-api.py 2013-01-08 17:25:08 UTC (rev
25719)
@@ -0,0 +1,158 @@
+#!/usr/bin/python
+import sys, xmlrpclib, getopt, getpass
+
+
+def usage():
+ print "GNUnet PlanetLab deployment and automation toolset\n\
+Arguments mandatory for long options are also mandatory for short options.\n\
+ -c, --config= configuration file\n\
+ -p, --user= Planetlab username\n\
+ -p. --password= Planetlab password\n\
+ -s, --slice= Planetlab slice\n\
+ -h, --help print this help\n\
+ -o, --operation= all,my\n\
+Report bugs to address@hidden \n\
+GNUnet home page: http://www.gnu.org/software/gnunet/ \n\
+General help using GNU software: http://www.gnu.org/gethelp/"
+
+# configuration
+pl_user = None
+pl_password = None
+pl_slicename = None
+cfgfile = None
+op = None
+
+def parse_arg ():
+ global cfgfile
+ global pl_user
+ global pl_password
+ global pl_slicename
+ global op
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "hc:u:p:s:o:", ["help",
"config", "pl_user=", "pl_password=", "slice=", "operation="])
+ except getopt.GetoptError, err:
+ # print help information and exit:
+ print str(err) # will print something like "option -a not recognized"
+ usage()
+ sys.exit(2)
+ for o, a in opts:
+ if o in ("-h", "--help"):
+ usage()
+ sys.exit()
+ elif o in ("-u", "--pl_user"):
+ pl_user = a
+ elif o in ("-p", "--pl_password"):
+ pl_password = a
+ elif o in ("-c", "--config"):
+ cfgfile = a
+ elif o in ("-s", "--slice"):
+ pl_slicename = a
+ elif o in ("-o", "--operation"):
+ if (a == "all"):
+ op = "all"
+ elif (a == "my"):
+ op = "my"
+ else:
+ usage()
+ sys.exit()
+ else:
+ assert False, "unhandled option"
+
+def update_conf (configuration):
+ if (None != pl_user):
+ configuration.pl_user = pl_user
+ if (None != pl_password):
+ configuration.pl_password = pl_password
+ if (None != pl_slicename):
+ configuration.pl_slicename = pl_slicename
+ if (None != pl_password):
+ configuration.pl_password = pl_password
+
+def list_my_nodes (configuration):
+ # PlanetLab XML RPC server
+ server = xmlrpclib.ServerProxy(configuration.pl_api_url)
+ # PlanetLab auth struct
+ auth = {}
+ auth['Username'] = configuration.pl_username
+ auth['AuthString'] = configuration.pl_password
+ auth['AuthMethod'] = "password"
+ # PlanetLab Slice data
+ slice_data = {}
+ slice_data['name'] = configuration.pl_slicename
+
+ # request nodes assigned to slice
+ try:
+ node_ids = server.GetSlices(auth, [slice_data['name']],
['node_ids'])[0]['node_ids']
+ node_hostnames = [node['hostname'] for node in server.GetNodes(auth,
node_ids, ['hostname'])]
+
+ for node in node_hostnames:
+ print node
+ except Exception as e:
+ print "Error while retrieving node list: " + str(e)
+
+def list_all_nodes (configuration):
+ # PlanetLab XML RPC server
+ server = xmlrpclib.ServerProxy(configuration.pl_api_url)
+ # PlanetLab auth struct
+ auth = {}
+ auth['Username'] = configuration.pl_username
+ auth['AuthString'] = configuration.pl_password
+ auth['AuthMethod'] = "password"
+ # PlanetLab Slice data
+ slice_data = {}
+ slice_data['name'] = configuration.pl_slicename
+
+ # request all sites on PL
+ try:
+ sites =
server.GetSites(auth,{},['site_id','name','latitude','longitude'])
+ nsites = len(sites)
+ except Exception as e:
+ print "Error while retrieving site list: " + str(e)
+ # request all nodes on PL
+ filter_dict = {"boot_state":"boot"}
+ try:
+ nodes =
server.GetNodes(auth,filter_dict,['site_id','node_id','hostname','boot_state'])
+ nnodes = len(nodes)
+ for node in nodes:
+ print node.get('hostname')
+ except Exception as e:
+ print "Error while retrieving node list: " + str(e)
+
+def main():
+ global cfgfile
+ global op
+ #import gplmt
+ import gplmt.Configuration as Configuration
+ import gplmt.Util as Util
+
+ logger = Util.Logger (False)
+ # Parse command line arguments
+ parse_arg ()
+ configuration = Configuration.Configuration (cfgfile, logger)
+ configuration.load ()
+ update_conf (configuration)
+
+ if ((configuration.pl_username == "") or
+ (configuration.pl_slicename == "")):
+ #usage ()
+ sys.exit (2)
+ if (configuration.pl_api_url == ""):
+ # PlanetLab Europe
+ configuration.pl_api_url = "https://www.planet-lab.eu/PLCAPI/"
+ if (configuration.pl_password == ""):
+ print "Please enter PlanetLab password:"
+ configuration.pl_password = getpass.getpass()
+
+ if (op == "all"):
+ list_all_nodes (configuration)
+ elif (op == "my"):
+ list_my_nodes (configuration)
+ else:
+ usage()
+ sys.exit()
+
+
+if (__name__ == "__main__"):
+ # Modify search path to include gplmt
+ sys.path.append('../')
+ main ()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25719 - gnunet-planetlab/gplmt/scripts,
gnunet <=