[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r23046 - gnunet-planetlab/planetlab-api
From: |
gnunet |
Subject: |
[GNUnet-SVN] r23046 - gnunet-planetlab/planetlab-api |
Date: |
Fri, 3 Aug 2012 12:54:47 +0200 |
Author: wachs
Date: 2012-08-03 12:54:47 +0200 (Fri, 03 Aug 2012)
New Revision: 23046
Added:
gnunet-planetlab/planetlab-api/add_slice_to_all_nodes.py
gnunet-planetlab/planetlab-api/delete_slice_from_nodes.py
Removed:
gnunet-planetlab/planetlab-api/addnodes.py
Log:
Copied: gnunet-planetlab/planetlab-api/add_slice_to_all_nodes.py (from rev
23011, gnunet-planetlab/planetlab-api/addnodes.py)
===================================================================
--- gnunet-planetlab/planetlab-api/add_slice_to_all_nodes.py
(rev 0)
+++ gnunet-planetlab/planetlab-api/add_slice_to_all_nodes.py 2012-08-03
10:54:47 UTC (rev 23046)
@@ -0,0 +1,69 @@
+#!/usr/bin/python
+
+# Add slice to all available nodes in state "booted"
+
+
+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:
+ 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')
+
+ for node in nodes:
+ node_str.append(node.get('hostname'))
+
+ res = server.AddSliceToNodes(auth,slice,node_str)
+ if (res == 1):
+ print 'Added ' +str(nnodes)+ ' to slice ' + slice
+ sys.stdout.flush()
+except Exception as e:
+ print "Error while adding nodes to list: " + str(e)
+
Deleted: gnunet-planetlab/planetlab-api/addnodes.py
===================================================================
--- gnunet-planetlab/planetlab-api/addnodes.py 2012-08-03 09:28:48 UTC (rev
23045)
+++ gnunet-planetlab/planetlab-api/addnodes.py 2012-08-03 10:54:47 UTC (rev
23046)
@@ -1,69 +0,0 @@
-#!/usr/bin/python
-
-# Add 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:
- 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 nodes 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')
-
- for node in nodes:
- node_str.append(node.get('hostname'))
-
- res = server.AddSliceToNodes(auth,slice,node_str)
- if (res == 1):
- print 'Added ' +str(nnodes)+ ' to slice ' + slice
- sys.stdout.flush()
-except Exception as e:
- print "Error while adding nodes to list: " + str(e)
-
Added: gnunet-planetlab/planetlab-api/delete_slice_from_nodes.py
===================================================================
--- gnunet-planetlab/planetlab-api/delete_slice_from_nodes.py
(rev 0)
+++ gnunet-planetlab/planetlab-api/delete_slice_from_nodes.py 2012-08-03
10:54:47 UTC (rev 23046)
@@ -0,0 +1,93 @@
+#!/usr/bin/python
+# Add slice from all nodes listed in file
+
+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/"
+
+
+
+import sys, os, urllib, xmlrpclib, socket, getopt
+
+user = ''
+password = ''
+slice = ''
+filename =''
+
+# 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"):
+ slice = a
+ elif o in ("-f", "--file"):
+ filename = a
+ else:
+ assert False, "unhandled option"
+
+
+# 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 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)
+
+try:
+ fobj = open (self.filename, "r")
+ for line in fobj:
+ line = line.strip()
+ self.logger.log ("Found node '" + line + "'")
+ self.nodes.append(line)
+ fobj.close()
+except IOError:
+ print "File " + self.filename + " not found"
+
+
+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)
+
+
\ No newline at end of file
Property changes on: gnunet-planetlab/planetlab-api/delete_slice_from_nodes.py
___________________________________________________________________
Added: svn:executable
+ *
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r23046 - gnunet-planetlab/planetlab-api,
gnunet <=