attempt to avoid remote qemus from hanging
[tests.git] / system / TestNode.py
index aacd63d..2bc232a 100644 (file)
@@ -11,7 +11,7 @@ class TestNode:
        self.test_plc=test_plc
        self.test_site=test_site
        self.node_spec=node_spec
-
+        
     def name(self):
         return self.node_spec['node_fields']['hostname']
     
@@ -30,7 +30,7 @@ class TestNode:
     def buildname(self):
         return self.test_plc.options.buildname
         
-    def areaname (self):
+    def nodedir (self):
         if self.is_qemu():
             return "qemu-%s"%self.name()
         else:
@@ -103,12 +103,12 @@ class TestNode:
 
     # Do most of the stuff locally - will be pushed on host_box - *not* the plc - later if needed
     def prepare_area(self):
-        utils.system("rm -rf %s"%self.areaname())
-        utils.system("mkdir %s"%self.areaname())
+        utils.system("rm -rf %s"%self.nodedir())
+        utils.system("mkdir %s"%self.nodedir())
         #create the tar log file
         utils.system("rm -rf nodeslogs && mkdir nodeslogs")
         if self.is_qemu():
-            utils.system("rsync -v -a --exclude .svn template-qemu/ %s/"%self.areaname())
+            utils.system("rsync -v -a --exclude .svn template-qemu/ %s/"%self.nodedir())
 
     def create_boot_cd(self):
         utils.header("Calling GetBootMedium for %s"%self.name())
@@ -119,7 +119,7 @@ class TestNode:
         if (encoded == ''):
             raise Exception, 'GetBootmedium failed'
 
-        filename="%s/%s.iso"%(self.areaname(),self.name())
+        filename="%s/%s.iso"%(self.nodedir(),self.name())
         utils.header('Storing boot medium into %s'%filename)
         file(filename,'w').write(base64.b64decode(encoded))
     
@@ -127,20 +127,23 @@ class TestNode:
         if not self.is_qemu():
             return
         mac=self.node_spec['network_fields']['mac']
-        conf_filename="%s/start-qemu.conf"%(self.areaname())
+        hostname=self.node_spec['node_fields']['hostname']
+        conf_filename="%s/qemu.conf"%(self.nodedir())
         utils.header('Storing qemu config for %s in %s'%(self.name(),conf_filename))
         file=open(conf_filename,'w')
         file.write('MACADDR=%s\n'%mac)
         file.write('NODE_ISO=%s.iso\n'%self.name())
+        file.write('HOSTNAME=%s\n'%hostname)
         file.close()
 
         # if relevant, push the qemu area onto the host box
         if ( not self.test_box().is_local()):
             utils.header ("Transferring configuration files for node %s onto %s"%(self.name(),self.host_box()))
-            self.test_box().clean_dir()
-            self.test_box().mkdir()
-            self.test_box().copy(self.areaname(),recursive=True)
+#            self.test_box().clean_dir(self.buildname())
+            self.test_box().mkdir("nodeslogs")
+            self.test_box().copy(self.nodedir(),recursive=True)
 
+            
     def start_node (self,options):
         model=self.node_spec['node_fields']['model']
         #starting the Qemu nodes before 
@@ -154,8 +157,14 @@ class TestNode:
         utils.header("Starting qemu node %s on %s"%(self.name(),test_box.hostname()))
 
         test_box.run_in_buildname("qemu-%s/env-qemu start >> nodeslogs/%s.log"%(self.name(),self.name()))
-        test_box.run_in_buildname("qemu-%s/start-qemu-node 2>&1 >> nodeslogs/%s.log &"%(
-                self.name(),self.name()))
+        # kick it off in background, as it would otherwise hang
+        test_box.run_in_buildname("qemu-%s/start-qemu-node 2>&1 >> nodeslogs/%s.log &"%(self.name(),self.name()),True)
+
+    def list_qemu (self):
+        utils.header("Listing qemu for host %s on box %s"%(self.name(),self.test_box().hostname()))
+        command="qemu-%s/kill-qemu-node -l %s"%(self.name(),self.name())
+        self.test_box().run_in_buildname(command)
+        return True
 
     def kill_qemu (self):
         #Prepare the log file before killing the nodes
@@ -164,6 +173,6 @@ class TestNode:
             utils.header("Failed to get the nodes log files")
         # kill the right processes 
         utils.header("Stopping qemu for host %s on box %s"%(self.name(),self.test_box().hostname()))
-        command="qemu_kill.sh %s"%self.name()
+        command="qemu-%s/kill-qemu-node %s"%(self.name(),self.name())
         self.test_box().run_in_buildname(command)
         return True