[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25718 - gnunet-planetlab/gplmt/scripts
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25718 - gnunet-planetlab/gplmt/scripts |
Date: |
Tue, 8 Jan 2013 18:15:13 +0100 |
Author: wachs
Date: 2013-01-08 18:15:12 +0100 (Tue, 08 Jan 2013)
New Revision: 25718
Modified:
gnunet-planetlab/gplmt/scripts/getmynodes.py
Log:
combine scripts
Modified: gnunet-planetlab/gplmt/scripts/getmynodes.py
===================================================================
--- gnunet-planetlab/gplmt/scripts/getmynodes.py 2013-01-08 17:02:53 UTC
(rev 25717)
+++ gnunet-planetlab/gplmt/scripts/getmynodes.py 2013-01-08 17:15:12 UTC
(rev 25718)
@@ -10,6 +10,7 @@
-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/"
@@ -19,16 +20,16 @@
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:", ["help",
"config", "pl_user=", "pl_password=", "slice="])
+ 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"
@@ -39,13 +40,21 @@
usage()
sys.exit()
elif o in ("-u", "--pl_user"):
- pl_username = a
+ 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
+ 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"
@@ -59,7 +68,7 @@
if (None != pl_password):
configuration.pl_password = pl_password
-def run_pl_api (configuration):
+def list_my_nodes (configuration):
# PlanetLab XML RPC server
server = xmlrpclib.ServerProxy(configuration.pl_api_url)
# PlanetLab auth struct
@@ -81,9 +90,37 @@
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
@@ -106,8 +143,15 @@
print "Please enter PlanetLab password:"
configuration.pl_password = getpass.getpass()
- run_pl_api (configuration)
+ 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('../')
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25718 - gnunet-planetlab/gplmt/scripts,
gnunet <=