*kill all the Qemu instance when stopping nodes.
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 23 Jan 2008 19:07:22 +0000 (19:07 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Wed, 23 Jan 2008 19:07:22 +0000 (19:07 +0000)
*Restore the network configuration in the hosts machines when the all Qemus emulation are shut down.

system/TestNode.py
system/TestPlc.py

index 0461a88..248f6c9 100644 (file)
@@ -144,3 +144,7 @@ class TestNode:
         utils.system("ssh root@%s ~/%s/env-qemu start "%(host_machine, dest_dir ))
         utils.system("ssh  root@%s DISPLAY=%s  ~/%s/start-qemu-node %s & "%( host_machine, display, dest_dir, dest_dir))
         
+    def stop_qemu(self,host_machine, hostname):
+        utils.header('Stoping qemu emulation of %s on the host machine %s and Restoring the initial network'
+                     %(hostname,host_machine))
+        utils.system("ssh root@%s ~/qemu-%s/env-qemu stop "%(host_machine, hostname ))
index fee41e0..f586694 100644 (file)
@@ -96,7 +96,20 @@ class TestPlc:
         utils.system('pgrep vmplayer | xargs -r kill ')
         utils.system('pgrep vmware | xargs -r kill -9')
         utils.system('pgrep vmplayer | xargs -r kill -9')
-        
+
+    def kill_all_qemus(self):
+        for site_spec in self.plc_spec['sites']:
+            test_site = TestSite (self,site_spec)
+            for node_spec in site_spec['nodes']:
+                test_node=TestNode (self,test_site,node_spec)
+                model=node_spec['node_fields']['model']
+                host_machine=node_spec['node_fields']['host_machine']
+                hostname=node_spec['node_fields']['hostname']
+                print model
+                if model.find("qemu") >= 0:
+                    utils.system('ssh root@%s  killall qemu'%host_machine)
+                    test_node.stop_qemu(host_machine,hostname)
+                    
     #################### step methods
 
     ### uninstall
@@ -345,6 +358,7 @@ class TestPlc:
         
     def start_nodes (self, options):
         self.kill_all_vmwares()
+        self.kill_all_qemus()
         utils.header("Starting vmware nodes")
         for site_spec in self.plc_spec['sites']:
             TestSite(self,site_spec).start_nodes (options)
@@ -352,6 +366,7 @@ class TestPlc:
 
     def stop_nodes (self, options):
         self.kill_all_vmwares ()
+        self.kill_all_qemus()
         return True
 
     # returns the filename to use for sql dump/restore, using options.dbname if set