[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25722 - gnunet-planetlab/gplmt/scripts
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25722 - gnunet-planetlab/gplmt/scripts |
Date: |
Tue, 8 Jan 2013 19:03:57 +0100 |
Author: wachs
Date: 2013-01-08 19:03:57 +0100 (Tue, 08 Jan 2013)
New Revision: 25722
Removed:
gnunet-planetlab/gplmt/scripts/delete_slice_from_nodes.py
Modified:
gnunet-planetlab/gplmt/scripts/gplmt-api.py
Log:
next script
Deleted: gnunet-planetlab/gplmt/scripts/delete_slice_from_nodes.py
===================================================================
--- gnunet-planetlab/gplmt/scripts/delete_slice_from_nodes.py 2013-01-08
17:52:48 UTC (rev 25721)
+++ gnunet-planetlab/gplmt/scripts/delete_slice_from_nodes.py 2013-01-08
18:03:57 UTC (rev 25722)
@@ -1,90 +0,0 @@
-#!/usr/bin/python
-# Add slice from 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 (plslice == None) or (user ==
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
-test = list()
-try:
- fobj = open (filename, "r")
- for line in fobj:
- line = line.strip()
- print "Found node '" + line + "'"
- test.append(line)
-
-
- fobj.close()
-except IOError:
- print "File '" + filename + "' not found"
- sys.exit(2)
-
-try:
- res = server.DeleteSliceFromNodes (auth, plslice, test)
- if (res == 1):
- print "Deleted nodes :" + str(test)
- 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:52:48 UTC (rev
25721)
+++ gnunet-planetlab/gplmt/scripts/gplmt-api.py 2013-01-08 18:03:57 UTC (rev
25722)
@@ -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, add_nodes_all\n\
+ -o, --operation= all,my,add_nodes_file, add_nodes_all, del_nodes_file\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/"
@@ -60,7 +60,9 @@
elif (a == "add_nodes_file"):
op = "add_nodes_file"
elif (a == "add_nodes_all"):
- op = "add_nodes_all"
+ op = "add_nodes_all"
+ elif (a == "del_nodes_file"):
+ op = "del_nodes_file"
else:
usage()
sys.exit()
@@ -84,7 +86,7 @@
nodes = list()
for line in fobj:
line = line.strip()
- print "Found node '" + line + "'"
+ #print "Found node '" + line + "'"
nodes.append(line)
return nodes
@@ -199,11 +201,36 @@
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
+ print 'Added slice ' + configuration.pl_slicename + "to nodes " +
str(nodes)
sys.stdout.flush()
+ else:
+ print "Failed to add nodes :" + str(nodes)+ " to slice " +
configuration.pl_slicename
except Exception as e:
print "Error while adding nodes to list: " + str(e)
+def del_nodes (configuration, nodes):
+ 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:
+ res = server.DeleteSliceFromNodes (auth, configuration.pl_slicename,
nodes)
+ if (res == 1):
+ print "Deleted nodes :" + str(nodes) + " from slice " +
configuration.pl_slicename
+ sys.stdout.flush()
+ else:
+ print "Failed to delete node :" + str(nodes)+ " from slice " +
configuration.pl_slicename
+ except Exception as e:
+ print "Failed to delete node :" + str(e)+ " from slice " +
configuration.pl_slicename
+
+
def main():
global nodesfile
global cfgfile
@@ -246,6 +273,8 @@
list_my_nodes (configuration)
elif ((None != nodes) and (op == "add_nodes_file")):
add_to_nodes(configuration, nodes)
+ elif ((None != nodes) and (op == "del_nodes_file")):
+ del_nodes (configuration, nodes)
elif (op == "add_nodes_all"):
add_to_all_nodes(configuration)
else:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25722 - gnunet-planetlab/gplmt/scripts,
gnunet <=