can clean nodes
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 3 Jan 2008 16:00:05 +0000 (16:00 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 3 Jan 2008 16:00:05 +0000 (16:00 +0000)
system/TestMain.py
system/TestNode.py
system/TestPlc.py

index f88495c..7e5a09f 100755 (executable)
@@ -18,7 +18,7 @@ default_steps = ['uninstall','install','configure', 'start', 'store_keys',
                  'bootcd', 'start_nodes', 
                  'check-nodes', 'check-slices' ]
 other_steps = [ 'fresh-install', 'stop', 'install_vserver_create', 'install_vserver_native',
-                'clean_sites', 'clean_slices' , 'clean_keys',
+                'clean_sites', 'clean_nodes', 'clean_slices', 'clean_keys',
                 'stop_nodes' ,  'db_dump' , 'db_restore',
                 ]
 
index b30ce8f..eb46221 100644 (file)
@@ -28,6 +28,17 @@ class TestNode:
                                             self.node_spec['network_fields'])
         self.test_plc.server.UpdateNode(auth, self.name(), filter)
 
+    def delete_node (self):
+        # uses the right auth as far as poss.
+        try:
+            ownername = self.node_spec['owner']
+            user_spec = self.test_site.locate_user(ownername)
+            test_user = TestUser(self.test_plc,self.test_site,user_spec)
+            auth = test_user.auth()
+        except:
+            aut=self.test_plc.auth_root()
+        self.test_plc.server.DeleteNode(auth,self.name())
+
     def conffile(self,image,hostname,path):
         template='%s/template-vmplayer/node.vmx'%(path)
         actual='%s/vmplayer-%s/node.vmx'%(path,hostname)
index ae52b9e..3ec3dda 100644 (file)
@@ -200,12 +200,12 @@ class TestPlc:
         return self.do_sites(options)
     
     def clean_sites (self,options):
-        return self.do_sites(options,"delete")
+        return self.do_sites(options,action="delete")
     
     def do_sites (self,options,action="add"):
         for site_spec in self.plc_spec['sites']:
             test_site = TestSite (self,site_spec)
-            if (action == "delete"):
+            if (action != "add"):
                 utils.header("Deleting site %s in %s"%(test_site.name(),self.name()))
                 test_site.delete_site()
                 # deleted with the site
@@ -218,13 +218,25 @@ class TestPlc:
         return True
 
     def nodes (self, options):
+        return self.do_nodes(options)
+    def clean_nodes (self, options):
+        return self.do_nodes(options,action="delete")
+
+    def do_nodes (self, options,action="add"):
         for site_spec in self.plc_spec['sites']:
             test_site = TestSite (self,site_spec)
-            utils.header("Creating nodes for site %s in %s"%(test_site.name(),self.name()))
-            for node_spec in site_spec['nodes']:
-                utils.show_spec('Creating node %s'%node_spec,node_spec)
-                test_node = TestNode (self,test_site,node_spec)
-                test_node.create_node ()
+            if action != "add":
+                utils.header("Deleting nodes in site %s"%test_site.name())
+                for node_spec in site_spec['nodes']:
+                    test_node=TestNode(self,test_site,node_spec)
+                    utils.header("Deleting %s"%test_node.name())
+                    test_node.delete_node()
+            else:
+                utils.header("Creating nodes for site %s in %s"%(test_site.name(),self.name()))
+                for node_spec in site_spec['nodes']:
+                    utils.show_spec('Creating node %s'%node_spec,node_spec)
+                    test_node = TestNode (self,test_site,node_spec)
+                    test_node.create_node ()
         return True
 
     def bootcd (self, options):