[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25721 - gnunet-planetlab/gplmt/scripts
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25721 - gnunet-planetlab/gplmt/scripts |
Date: |
Tue, 8 Jan 2013 18:52:48 +0100 |
Author: wachs
Date: 2013-01-08 18:52:48 +0100 (Tue, 08 Jan 2013)
New Revision: 25721
Removed:
gnunet-planetlab/gplmt/scripts/add_slice_to_all_nodes.py
gnunet-planetlab/gplmt/scripts/add_slice_to_nodes.py
Modified:
gnunet-planetlab/gplmt/scripts/gplmt-api.py
Log:
next script merge
Deleted: gnunet-planetlab/gplmt/scripts/add_slice_to_all_nodes.py
===================================================================
--- gnunet-planetlab/gplmt/scripts/add_slice_to_all_nodes.py 2013-01-08
17:43:26 UTC (rev 25720)
+++ gnunet-planetlab/gplmt/scripts/add_slice_to_all_nodes.py 2013-01-08
17:52:48 UTC (rev 25721)
@@ -1,90 +0,0 @@
-#!/usr/bin/python
-
-# Add slice to all available nodes in state "booted"
-import getopt, sys, xmlrpclib
-
-def usage():
- print "GNUnet PlanetLab deployment and automation toolset\n\
-Arguments mandatory for long options are also mandatory for short options.\n\
- -u, --user= Planetlab username\n\
- -p, --password= Planetlab password\n\
- -s, --slice= Planetlab slice\n\
- -h, --help print this help\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/"
-
-
-user = None
-password = None
-plslice = None
-
-try:
- opts, args = getopt.getopt(sys.argv[1:], "hu:p:s:", ["help", "user=",
"password=", "slice="])
-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", "--user"):
- user = a
- elif o in ("-p", "--password"):
- password = a
- elif o in ("-s", "--slice"):
- plslice = a
- else:
- assert False, "unhandled option"
-
-if ((user == None) or (password == None) or (slice == None)):
- usage()
- sys.exit(2)
-
-
-
-# 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:
- sys.stdout.write('Retrieving PL sites list... ')
- sys.stdout.flush()
- sites = server.GetSites(auth,{},['site_id','name','latitude','longitude'])
- nsites = len(sites)
- sys.stdout.write('Received ' + str(nsites) + ' sites\n\n')
- sys.stdout.flush()
-except Exception as e:
- print "Error while retrieving sites list: " + str(e)
-
-
-# request all nodes on PL
-sys.stdout.write('Retrieving PL nodes list for sites')
-sys.stdout.flush()
-filter_dict = {"boot_state":"boot"}
-try:
- nodes =
server.GetNodes(auth,filter_dict,['site_id','node_id','hostname','boot_state'])
- nnodes = len(nodes)
- sys.stdout.write('... got ' +str(nnodes)+ ' nodes \n\n')
- node_str = ""
- for node in nodes:
- node_str.append(node.get('hostname'))
- res = server.AddSliceToNodes(auth,plslice,node_str)
- if (res == 1):
- print 'Added ' +str(nnodes)+ ' to slice ' + plslice
- sys.stdout.flush()
-except Exception as e:
- print "Error while adding nodes to list: " + str(e)
-
Deleted: gnunet-planetlab/gplmt/scripts/add_slice_to_nodes.py
===================================================================
--- gnunet-planetlab/gplmt/scripts/add_slice_to_nodes.py 2013-01-08
17:43:26 UTC (rev 25720)
+++ gnunet-planetlab/gplmt/scripts/add_slice_to_nodes.py 2013-01-08
17:52:48 UTC (rev 25721)
@@ -1,91 +0,0 @@
-#!/usr/bin/python
-# Add slice to all nodes listed in file
-import sys, xmlrpclib, getopt
-
-def usage():
- print "GNUnet PlanetLab deployment and automation toolset\n\
-Arguments mandatory for long options are also mandatory for short options.\n\
- -u, --user= Planetlab username\n\
- -p, --password= Planetlab password\n\
- -s, --slice= Planetlab slice\n\
- -f, --file= file containing nodes\n\
- -h, --help print this help\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/"
-
-user = None
-password = None
-plslice = None
-filename = None
-
-# Parse command line arguments
-
-try:
- opts, args = getopt.getopt(sys.argv[1:], "hu:p:s:f:", ["help", "user=",
"password=", "slice=", "file="])
-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", "--user"):
- user = a
- elif o in ("-p", "--password"):
- password = a
- elif o in ("-s", "--slice"):
- plslice = a
- elif o in ("-f", "--file"):
- filename = a
- else:
- assert False, "unhandled option"
-
-if (((user == None) or (password == None) or (slice == None)) or
- (filename == None)):
- usage ()
- sys.exit (2)
-
-# 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"
-
-nodes = list()
-
-slice_data = {}
-slice_data['name'] = plslice
-
-
-# request nodes assigned to slice
-nodes = list()
-try:
- fobj = open (filename, "r")
- for line in fobj:
- line = line.strip()
- print "Found node '" + line + "'"
- nodes.append(line)
-
-
- fobj.close()
-except IOError:
- print "File '" + filename + "' not found"
- sys.exit(2)
-
-try:
- res = server.AddSliceToNodes (auth, plslice, nodes)
- if (res == 1):
- print "Added slice '" + plslice+ "' to nodes :" + str(nodes)
- sys.stdout.flush()
-except Exception as e:
- print "Failed to delete node :" + str(e)
Modified: gnunet-planetlab/gplmt/scripts/gplmt-api.py
===================================================================
--- gnunet-planetlab/gplmt/scripts/gplmt-api.py 2013-01-08 17:43:26 UTC (rev
25720)
+++ gnunet-planetlab/gplmt/scripts/gplmt-api.py 2013-01-08 17:52:48 UTC (rev
25721)
@@ -11,7 +11,7 @@
-s, --slice= Planetlab slice\n\
-n, --nodes= Files containing nodes\n\
-h, --help print this help\n\
- -o, --operation= all,my,add_nodes_file\n\
+ -o, --operation= all,my,add_nodes_file, add_nodes_all\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/"
@@ -58,7 +58,9 @@
elif (a == "my"):
op = "my"
elif (a == "add_nodes_file"):
- op = "add_nodes_file"
+ op = "add_nodes_file"
+ elif (a == "add_nodes_all"):
+ op = "add_nodes_all"
else:
usage()
sys.exit()
@@ -160,7 +162,48 @@
except Exception as e:
print "Failed to add node :" + str(e)
+
+def add_to_all_nodes (configuration):
+ 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:
+ sys.stdout.write('Retrieving PL sites list... ')
+ sys.stdout.flush()
+ sites =
server.GetSites(auth,{},['site_id','name','latitude','longitude'])
+ nsites = len(sites)
+ sys.stdout.write('Received ' + str(nsites) + ' sites\n\n')
+ sys.stdout.flush()
+ except Exception as e:
+ print "Error while retrieving sites list: " + str(e)
+
+ # request all nodes on PL
+ sys.stdout.write('Retrieving PL nodes list for sites')
+ sys.stdout.flush()
+ filter_dict = {"boot_state":"boot"}
+ try:
+ nodes =
server.GetNodes(auth,filter_dict,['site_id','node_id','hostname','boot_state'])
+ nnodes = len(nodes)
+ sys.stdout.write('... got ' +str(nnodes)+ ' nodes \n\n')
+ node_str = list()
+ for node in nodes:
+ print node.get('hostname')
+ node_str.append(node.get('hostname'))
+ res = server.AddSliceToNodes(auth, configuration.pl_slicename,
node_str)
+ if (res == 1):
+ print 'Added ' +str(nnodes)+ ' to slice ' + plslice
+ sys.stdout.flush()
+ except Exception as e:
+ print "Error while adding nodes to list: " + str(e)
+
def main():
global nodesfile
global cfgfile
@@ -202,7 +245,9 @@
elif (op == "my"):
list_my_nodes (configuration)
elif ((None != nodes) and (op == "add_nodes_file")):
- add_to_nodes(configuration, nodes)
+ add_to_nodes(configuration, nodes)
+ elif (op == "add_nodes_all"):
+ add_to_all_nodes(configuration)
else:
usage()
sys.exit()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25721 - gnunet-planetlab/gplmt/scripts,
gnunet <=