[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r22789 - in gnunet-planetlab/gplmt: . contrib
From: |
gnunet |
Subject: |
[GNUnet-SVN] r22789 - in gnunet-planetlab/gplmt: . contrib |
Date: |
Fri, 20 Jul 2012 14:21:08 +0200 |
Author: wachs
Date: 2012-07-20 14:21:08 +0200 (Fri, 20 Jul 2012)
New Revision: 22789
Modified:
gnunet-planetlab/gplmt/Configuration.py
gnunet-planetlab/gplmt/Nodes.py
gnunet-planetlab/gplmt/README
gnunet-planetlab/gplmt/Tasks.py
gnunet-planetlab/gplmt/Worker.py
gnunet-planetlab/gplmt/contrib/test.conf
gnunet-planetlab/gplmt/gplmt.py
Log:
- Added Planetlab Api support
Modified: gnunet-planetlab/gplmt/Configuration.py
===================================================================
--- gnunet-planetlab/gplmt/Configuration.py 2012-07-20 12:02:27 UTC (rev
22788)
+++ gnunet-planetlab/gplmt/Configuration.py 2012-07-20 12:21:08 UTC (rev
22789)
@@ -30,7 +30,11 @@
self.filename = filename
self.logger = logger
self.notifications = ""
- self.slicename = ""
+ self.pl_slicename = ""
+ self.pl_api_url = ""
+ self.pl_username = ""
+ self.pl_password = ""
+ self.pl_use_nodes = False
self.taskfile = ""
self.nodesfile = ""
self.ssh_add_unkown_hostkeys = False
@@ -49,11 +53,27 @@
# required values
try:
- self.slicename = config.get("planetlab", "slice")
+ self.pl_slicename = config.get("planetlab", "slice")
except ConfigParser.NoOptionError as e:
print "Error parsing configuration: " + str (e)
return False
# optional values
+ try:
+ self.pl_use_nodes = config.getboolean ("planetlab", "use_pl_nodes")
+ except ConfigParser.NoOptionError as e:
+ pass
+ try:
+ self.pl_api_url = config.get("planetlab", "api_url")
+ except ConfigParser.NoOptionError as e:
+ pass
+ try:
+ self.pl_username = config.get("planetlab", "username")
+ except ConfigParser.NoOptionError as e:
+ pass
+ try:
+ self.pl_password = config.get("planetlab", "password")
+ except ConfigParser.NoOptionError as e:
+ pass
try:
# gplmt options
self.taskfile = config.get("gplmt", "tasks")
Modified: gnunet-planetlab/gplmt/Nodes.py
===================================================================
--- gnunet-planetlab/gplmt/Nodes.py 2012-07-20 12:02:27 UTC (rev 22788)
+++ gnunet-planetlab/gplmt/Nodes.py 2012-07-20 12:21:08 UTC (rev 22789)
@@ -21,6 +21,7 @@
# GNUnet Planetlab deployment and automation toolset
#
# Tasks
+import sys, os, urllib, xmlrpclib, socket
class Nodes:
def __init__(self, filename, logger):
@@ -42,3 +43,47 @@
return False
self.logger.log ("Loaded " + str(len(self.nodes)) + " nodes")
return True
+
+class PlanetLabNodes:
+ def __init__(self, configuration, logger):
+ assert (None != logger)
+ self.logger = logger
+ self.configuration = configuration
+ self.nodes = list ()
+ def load (self):
+ self.logger.log ("Retrieving nodes assigned to slice '" +
self.configuration.pl_slicename + "'")
+ if (self.configuration.pl_password == ""):
+ print "No PlanetLab password given in configuration fail!"
+ return False
+ if (self.configuration.pl_username == ""):
+ print "No PlanetLab username given in configuration, fail!"
+ return False
+ if (self.configuration.pl_api_url == ""):
+ print "No PlanetLab API url given in configuration, fail!"
+ return False
+ try:
+ server = xmlrpclib.ServerProxy(self.configuration.pl_api_url)
+ except:
+ print "Could not connect to PlanetLab API, fail!"
+ return False
+
+ slice_data = {}
+ slice_data['name'] = 'tumple_gnunet'
+
+ auth = {}
+ auth['Username'] = self.configuration.pl_username
+ auth['AuthString'] = self.configuration.pl_password
+ auth['AuthMethod'] = "password"
+
+ 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'])]
+ except:
+ print "Could not retrieve data from PlanetLab API, fail!"
+ return False
+
+ for node in node_hostnames:
+ self.logger.log ("Planetlab API returned: " + node)
+ self.nodes.append(node)
+ self.logger.log ("Planetlab API returned " + str(len(self.nodes)) + "
nodes")
+ return True
\ No newline at end of file
Modified: gnunet-planetlab/gplmt/README
===================================================================
--- gnunet-planetlab/gplmt/README 2012-07-20 12:02:27 UTC (rev 22788)
+++ gnunet-planetlab/gplmt/README 2012-07-20 12:21:08 UTC (rev 22789)
@@ -12,7 +12,14 @@
Additional information and documentation about gplmt can be found at
https://gnunet.org/gplmt.
+Features:
+=============
+- PlanetLab API integration to retrieve node list
+- SFTP support to copy data from and to nodes
+- Extensible task list
+- Extensible logging functionality
+
Dependencies:
=============
Modified: gnunet-planetlab/gplmt/Tasks.py
===================================================================
--- gnunet-planetlab/gplmt/Tasks.py 2012-07-20 12:02:27 UTC (rev 22788)
+++ gnunet-planetlab/gplmt/Tasks.py 2012-07-20 12:21:08 UTC (rev 22789)
@@ -196,7 +196,7 @@
self.name = "<Undefined>"
self.l = list ()
def load (self):
- self.logger.log ("Loading nodes file '" + self.filename + "'")
+ self.logger.log ("Loading tasks file '" + self.filename + "'")
try:
root = ElementTree.parse (self.filename).getroot()
if (None != root.attrib.get("name")):
Modified: gnunet-planetlab/gplmt/Worker.py
===================================================================
--- gnunet-planetlab/gplmt/Worker.py 2012-07-20 12:02:27 UTC (rev 22788)
+++ gnunet-planetlab/gplmt/Worker.py 2012-07-20 12:21:08 UTC (rev 22789)
@@ -106,7 +106,7 @@
sftp.put(task.src, task.dest)
sftp.close()
except paramiko.SSHException as e:
- g_logger.log (self.node + " : Task '"+ task.name + "' :" + e)
+ g_logger.log (self.node + " : Task '"+ task.name + "' :" + str(e))
result = Tasks.Taskresult.fail
pass
except (OSError, IOError) as e:
@@ -122,7 +122,7 @@
sftp.get (task.src, task.dest)
sftp.close()
except paramiko.SSHException as e:
- g_logger.log (self.node + " : Task '"+ task.name + "' :" + e)
+ g_logger.log (self.node + " : Task '"+ task.name + "' :" + str(e))
result = Tasks.Taskresult.fail
pass
except (OSError, IOError) as e:
@@ -153,11 +153,11 @@
g_logger.log (self.node + " : Not found " +
g_configuration.ssh_keyfile)
g_logger.log (self.node + " : Trying to connect to " +
- g_configuration.slicename + "@" + self.node +
+ g_configuration.pl_slicename + "@" + self.node +
" using password '" + g_configuration.ssh_password+
"' and private keyfile '" +str(keyfile)+ "'")
ssh.connect (self.node,
- username=g_configuration.slicename,
+ username=g_configuration.pl_slicename,
password=g_configuration.ssh_password,
key_filename=keyfile)
except (IOError,
Modified: gnunet-planetlab/gplmt/contrib/test.conf
===================================================================
--- gnunet-planetlab/gplmt/contrib/test.conf 2012-07-20 12:02:27 UTC (rev
22788)
+++ gnunet-planetlab/gplmt/contrib/test.conf 2012-07-20 12:21:08 UTC (rev
22789)
@@ -1,20 +1,31 @@
[gplmt]
-nodes = contrib/localhost.nodes
-#nodes = contrib/current.nodes
+#nodes = contrib/localhost.nodes
+nodes = contrib/current.nodes
#tasks = contrib/tasks.xml
-#tasks = contrib/simpletasks.xml
-tasks = contrib/sftp_tasks.xml
+tasks = contrib/simpletasks.xml
+#tasks = contrib/sftp_tasks.xml
# Which notification mechanism to use:
# simple: print messages to stdout
notification = simple
+[planetlab]
+#slice = mwachs
+slice = tumple_gnunet_deployment
+# Configuration for Planetlab API
+# Use PlanetLab nodes instead of nodes file
+use_pl_nodes = no
+# PlanetLab Europe
+api_url = https://www.planet-lab.eu/PLCAPI/
+# Planetlab
+#api_url = https://www.planet-lab.org/PLCAPI/
-[planetlab]
-slice = mwachs
-#slice = tumple_gnunet_deployment
+# Planetlab username
+username = address@hidden
+# Planetlab password
+password = <password>
[ssh]
# Order of ssh authentication:
Modified: gnunet-planetlab/gplmt/gplmt.py
===================================================================
--- gnunet-planetlab/gplmt/gplmt.py 2012-07-20 12:02:27 UTC (rev 22788)
+++ gnunet-planetlab/gplmt/gplmt.py 2012-07-20 12:21:08 UTC (rev 22789)
@@ -61,7 +61,7 @@
# Parse command line arguments
try:
- opts, args = getopt.getopt(sys.argv[1:], "hvc:n:t:", ["help",
"config=", "nodes=", "tasks="])
+ opts, args = getopt.getopt(sys.argv[1:], "hvc:n:t:ap:", ["help",
"config=", "nodes=", "tasks=", "all", "password"])
except getopt.GetoptError, err:
# print help information and exit:
print str(err) # will print something like "option -a not recognized"
@@ -78,7 +78,11 @@
elif o in ("-n", "--nodes"):
main.nodes_file = a
elif o in ("-t", "--tasks"):
- main.tasks_file = a
+ main.tasks_file = a
+ elif o in ("-a", "--all"):
+ main.pl_use_nodes = True
+ elif o in ("-p", "--password"):
+ main.pl_password = a
else:
assert False, "unhandled option"
@@ -111,12 +115,19 @@
else:
print "No tasks file given!\n"
usage()
- sys.exit(2)
+ sys.exit(2)
+ if (main.pl_password != ""):
+ configuration.pl_password = main.pl_password
# Load hosts files
- nodes = Nodes.Nodes (main.nodes_file, main.logger);
- if (nodes.load() == False):
- sys.exit(2)
+ if ((main.pl_use_nodes == True) or (configuration.pl_use_nodes == True)):
+ nodes = Nodes.PlanetLabNodes (configuration, main.logger)
+ if (nodes.load() == False):
+ sys.exit(2)
+ else:
+ nodes = Nodes.Nodes (main.nodes_file, main.logger);
+ if (nodes.load() == False):
+ sys.exit(2)
# Load actions file
tasks = Tasks.Tasks (main.tasks_file, main.logger);
@@ -143,6 +154,8 @@
-c, --config=FILENAME use configuration file FILENAME\n\
-n, --nodes=FILENAME use node file FILENAME\n\
-t, --tasks=FILENAME use tasks file FILENAME\n\
+ -a, --all use all nodes assigned to PlanetLab slice instead
of nodes file\n\
+ -p, --password password to acces PlanetLab API\n\
-h, --help print this help\n\
-V, --verbose be verbose \n\
Report bugs to address@hidden \n\
@@ -154,6 +167,8 @@
config_file = "";
nodes_file = "";
tasks_file = "";
+ pl_password = "";
+ pl_use_nodes = False;
logger = None;
def __init__(self):
self.verbose = False;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r22789 - in gnunet-planetlab/gplmt: . contrib,
gnunet <=