gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r23217 - in gnunet-planetlab/gplmt: contrib/tasklists contr


From: gnunet
Subject: [GNUnet-SVN] r23217 - in gnunet-planetlab/gplmt: contrib/tasklists contrib/tasklists/tests gplmt
Date: Tue, 14 Aug 2012 10:49:00 +0200

Author: wachs
Date: 2012-08-14 10:49:00 +0200 (Tue, 14 Aug 2012)
New Revision: 23217

Modified:
   gnunet-planetlab/gplmt/contrib/tasklists/test_run_per_host_tasks.xml
   gnunet-planetlab/gplmt/contrib/tasklists/tests/test_run_per_host.cmds
   gnunet-planetlab/gplmt/gplmt/Tasks.py
   gnunet-planetlab/gplmt/gplmt/Worker.py
Log:
per host cmd exec

Modified: gnunet-planetlab/gplmt/contrib/tasklists/test_run_per_host_tasks.xml
===================================================================
--- gnunet-planetlab/gplmt/contrib/tasklists/test_run_per_host_tasks.xml        
2012-08-14 07:58:08 UTC (rev 23216)
+++ gnunet-planetlab/gplmt/contrib/tasklists/test_run_per_host_tasks.xml        
2012-08-14 08:49:00 UTC (rev 23217)
@@ -10,8 +10,8 @@
         <stop_on_fail>true</stop_on_fail>
        </run> 
        <run_per_host id="1" name="get hostname">
-               <command_file>./tests/test_run_per_host.cmds</command_file>
-               <output_prefix>./tests/result_</output_prefix>
+               
<command_file>contrib/tasklists/tests/test_run_per_host.cmds</command_file>
+               <output_prefix>contrib/tests/result_</output_prefix>
         <timeout>10</timeout>
         <expected_return_code>0</expected_return_code>
         <expected_output></expected_output>

Modified: gnunet-planetlab/gplmt/contrib/tasklists/tests/test_run_per_host.cmds
===================================================================
--- gnunet-planetlab/gplmt/contrib/tasklists/tests/test_run_per_host.cmds       
2012-08-14 07:58:08 UTC (rev 23216)
+++ gnunet-planetlab/gplmt/contrib/tasklists/tests/test_run_per_host.cmds       
2012-08-14 08:49:00 UTC (rev 23217)
@@ -1,3 +1,4 @@
 # Format: <hostname>;<cmd>
 # Default command if hostname is not included : <empty>;<default cmd>
-;hostname -f
\ No newline at end of file
+planetlab10.millennium.berkeley.edu; hostname -f
+;date 
\ No newline at end of file

Modified: gnunet-planetlab/gplmt/gplmt/Tasks.py
===================================================================
--- gnunet-planetlab/gplmt/gplmt/Tasks.py       2012-08-14 07:58:08 UTC (rev 
23216)
+++ gnunet-planetlab/gplmt/gplmt/Tasks.py       2012-08-14 08:49:00 UTC (rev 
23217)
@@ -22,7 +22,6 @@
 #
 # Nodes
 try: 
-    import xml
     import sys
     from xml.parsers import expat  
     from minixsv import pyxsval as xsv 

Modified: gnunet-planetlab/gplmt/gplmt/Worker.py
===================================================================
--- gnunet-planetlab/gplmt/gplmt/Worker.py      2012-08-14 07:58:08 UTC (rev 
23216)
+++ gnunet-planetlab/gplmt/gplmt/Worker.py      2012-08-14 08:49:00 UTC (rev 
23217)
@@ -58,10 +58,43 @@
         self.node = node
         self.tasks = tasks
 
-    def exec_run_per_host (self, task, transport):  
-        print "HERE!"
+    def exec_run_per_host (self, task, transport):
+        found = False
+        default = None
+        cmd = None          
+        try:
+            f = open(task.command_file, 'r')
+            for line in f:
+                if (line[0] == '#'):
+                    continue;
+                sline = line.split (';',2)
+                if (sline[0] == self.node):
+                    cmd = sline[1]
+                    found = True
+                if (sline[0] == ''):
+                    default = sline[1]
+            f.close()
+        except IOError as e:
+            print str(e)
         
+        if (found == True):
+            g_logger.log (self.node + " : Found specific command '"+ cmd + "'")
+            task.command = cmd
+            task.arguments = ""
+        elif ((found == False) and (default != None)):
+            g_logger.log (self.node + " : Using default command '"+ default + 
"'")
+            task.command = default
+            task.arguments = ""
+        else:
+            g_logger.log (self.node + " : Task '"+ task.name + "' failed: no 
command to execute")
+            return Tasks.Taskresult.fail
+        self.exec_run(task, transport)
+        
     def exec_run (self, task, transport):
+        if ((task.command == None) and (task.arguments == None)):
+            g_logger.log (self.node + " : Task '"+ task.name + "' failed: no 
command to execute")
+            return Tasks.Taskresult.fail
+            
         try:
             channel = transport.open_session()
             channel.settimeout(1.0)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]