first step towards integrating http://svn.planet-lab.org/svn/tests/trunk/qaapi/qa...
[tests.git] / system / TestNode.py
index 5b38823..f990e71 100644 (file)
@@ -1,4 +1,4 @@
-import os, sys, time, base64
+import sys, os, os.path, time, base64
 import xmlrpclib
 
 import utils
@@ -68,7 +68,7 @@ class TestNode:
                        self.test_site.site_spec['site_fields']['login_base'],
                        self.node_spec['node_fields'])
         # create as reinstall to avoid user confirmation
-        server.UpdateNode(userauth, self.name(), {'boot_state':'rins'})
+        server.UpdateNode(userauth, self.name(), {'boot_state':'reinstall'})
         # populate network interfaces - primary
         server.AddInterface(userauth,self.name(),
                                             self.node_spec['network_fields'])
@@ -84,10 +84,10 @@ class TestNode:
                         nnid=nn['interface_id']
                         # locate or create node network attribute type
                         try:
-                            nnst = server.GetInterfaceSettingTypes(userauth,{'name':attribute})[0]
+                            nnst = server.GetTagTypes(userauth,{'name':attribute})[0]
                         except:
-                            nnst = server.AddInterfaceSettingType(rootauth,{'category':'test',
-                                                                              'name':attribute})
+                            nnst = server.AddTagType(rootauth,{'category':'test',
+                                                               'tagname':attribute})
                         # attach value
                         server.AddInterfaceSetting(userauth,nnid,attribute,value)
 
@@ -131,7 +131,7 @@ class TestNode:
 
     def reinstall_node (self):
         self.test_plc.apiserver.UpdateNode(self.test_plc.auth_root(),
-                                           self.name(),{'boot_state':'rins'})
+                                           self.name(),{'boot_state':'reinstall'})
         return True
     
     def configure_qemu(self):
@@ -208,3 +208,27 @@ class TestNode:
     def clear_known_hosts (self):
         TestSsh(self.name()).clear_known_hosts()
         return True
+
+    def check_sanity_node_script (self,local_script):
+        # get the plc's keys for entering the node
+        vservername=self.test_plc.vservername
+        key = "keys/%(vservername)s.rsa"%locals()
+        # push the script on the node's root context
+        ssh_handle = TestSsh(self.name(),
+                             buildname=self.buildname(),
+                             key=key)
+        ssh_handle.copy_home(local_script)
+        if ssh_handle.run("./"+os.path.basename(local_script)) != 0:
+            print "WARNING: sanity check script %s FAILED"
+            # xxx - temporary : always return true for now
+            #return False
+        return True
+    
+    def check_sanity_node (self):
+        # locate the relevant scripts - xxx
+        scripts = [ 'tests/qaapi/qa/tests/node/vsys_launch.pl' ]
+        overall = True
+        for script in scripts:
+            if not self.check_sanity_node_script (script):
+                overall = False
+        return overall