add safeboot_node target
[tests.git] / system / TestNode.py
index 5615095..380d8a9 100644 (file)
@@ -1,3 +1,6 @@
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA 
+#
 import sys, os, os.path, time, base64
 import xmlrpclib
 
@@ -137,6 +140,11 @@ class TestNode:
                                            self.name(),{'boot_state':'reinstall'})
         return True
     
+    def safeboot_node (self):
+        self.test_plc.apiserver.UpdateNode(self.test_plc.auth_root(),
+                                           self.name(),{'boot_state':'safeboot'})
+        return True
+    
     def configure_qemu(self):
         if not self.is_qemu():
             return
@@ -205,7 +213,7 @@ class TestNode:
         if not self.is_qemu():
             return True
         remote_log="%s/log.txt"%self.nodedir()
-        local_log="logs/node.qemu.%s.log"%self.name()
+        local_log="logs/node.qemu.%s.txt"%self.name()
         self.test_box().test_ssh.fetch(remote_log,local_log)
 
     def clear_known_hosts (self):
@@ -215,32 +223,33 @@ class TestNode:
     def create_test_ssh(self):
         # get the plc's keys for entering the node
         vservername=self.test_plc.vservername
-        # assuming we've run testplc.fetch_keys()
-        key = "keys/%(vservername)s.rsa"%locals()
+###        # assuming we've run testplc.fetch_keys()
+###        key = "keys/%(vservername)s.rsa"%locals()
+        # fetch_keys doesn't grab the root key anymore
+        key = "keys/key1.rsa"
         return TestSsh(self.name(), buildname=self.buildname(), key=key)
 
-    def check_sanity (self):
+    def check_hooks (self):
         extensions = [ 'py','pl','sh' ]
-        path='tests/qaapi/qa/tests/node/'
-        scripts=utils.locate_sanity_scripts ('node '+self.name(), path,extensions)
+        path='hooks/node'
+        scripts=utils.locate_hooks_scripts ('node '+self.name(), path,extensions)
         overall = True
         for script in scripts:
-            if not self.check_sanity_script (script):
+            if not self.check_hooks_script (script):
                 overall = False
         return overall
 
-    def check_sanity_script (self,local_script):
+    def check_hooks_script (self,local_script):
         # push the script on the node's root context
         script_name=os.path.basename(local_script)
-        utils.header ("NODE %s : running sanity check script %s"%(self.name(),script_name))
-        ssh_handle=self.create_test_ssh()
-        ssh_handle.copy_home(local_script)
-        if ssh_handle.run("./"+script_name) != 0:
-            utils.header ("WARNING: node sanity check script %s FAILED"%script_name)
-            print 'temporary : ignoring result and always return true for now'
+        utils.header ("NODE hook %s (%s)"%(script_name,self.name()))
+        test_ssh=self.create_test_ssh()
+        test_ssh.copy_home(local_script)
+        if test_ssh.run("./"+script_name) != 0:
+            utils.header ("WARNING: node hooks check script %s FAILED (ignored)"%script_name)
             #return False
             return True
         else:
-            utils.header ("SUCCESS: node sanity check script %s OK"%script_name)
+            utils.header ("SUCCESS: node hook %s OK"%script_name)
             return True