new SFA settings names (sfa_plc vs sfa_db)
[tests.git] / system / TestPlc.py
index a21f42f..c3acc6c 100644 (file)
@@ -92,7 +92,8 @@ class TestPlc:
         'initscripts', 'sites', 'nodes', 'slices', 'nodegroups', 'leases', SEP,
         'nodestate_reinstall', 'qemu_local_init','bootcd', 'qemu_local_config', SEP,
         'qemu_export', 'qemu_kill_mine', 'qemu_start', 'timestamp_qemu', SEP,
-       'sfa_install', 'sfa_configure', 'cross_sfa_configure', 'sfa_import', 'sfa_start', SEPSFA,
+       'sfa_install', 'sfa_tables_install', 'sfa_plc_install', 'sfa_client_install', SEPSFA,
+        'sfa_configure', 'cross_sfa_configure', 'sfa_start', 'sfa_import', SEPSFA,
         'sfi_configure@1', 'sfa_add_user@1', 'sfa_add_slice@1', 'sfa_discover@1', SEPSFA,
         'sfa_create_slice@1', 'sfa_check_slice_plc@1', SEPSFA, 
         'sfa_update_user@1', 'sfa_update_slice@1', 'sfa_view@1', 'sfa_utest@1',SEPSFA,
@@ -105,10 +106,8 @@ class TestPlc:
         'force_gather_logs', SEP,
         ]
     other_steps = [ 
-        'check_hooks',  
-        'free_all',
-        'show_boxes', 'local_list','local_rel','local_rel_plc','local_rel_qemu',SEP,
-        'plc_stop', 'vs_start', 'vs_stop', SEP,
+        'export', 'show_boxes', SEP,
+        'check_hooks', 'plc_stop', 'vs_start', 'vs_stop', SEP,
         'delete_initscripts', 'delete_nodegroups','delete_all_sites', SEP,
         'delete_sites', 'delete_nodes', 'delete_slices', 'keys_clean', SEP,
         'delete_leases', 'list_leases', SEP,
@@ -117,7 +116,7 @@ class TestPlc:
         'qemu_list_all', 'qemu_list_mine', 'qemu_kill_all', SEP,
         'sfa_plcclean', 'sfa_dbclean', 'sfa_stop','sfa_uninstall', 'sfi_clean', SEP,
         'plc_db_dump' , 'plc_db_restore', SEP,
-        'standby_1 through 20',SEP,
+        'standby_1_through_20',SEP,
         ]
 
     @staticmethod
@@ -129,7 +128,7 @@ class TestPlc:
         return step != SEP and step != SEPSFA
 
     # turn off the sfa-related steps when build has skipped SFA
-    # this is originally for centos5 as recent SFAs won't build on this platformb
+    # this is originally for centos5 as recent SFAs won't build on this platform
     @staticmethod
     def check_whether_build_has_sfa (rpms_url):
         # warning, we're now building 'sface' so let's be a bit more picky
@@ -199,6 +198,13 @@ class TestPlc:
     def run_in_guest_piped (self,local,remote):
         return utils.system(local+" | "+self.test_ssh.actual_command(self.host_to_guest(remote),keep_stdin=True))
 
+    # does a yum install in the vs, ignore yum retcod, check with rpm
+    def yum_install (self, rpms):
+        if isinstance (rpms, list): 
+            rpms=" ".join(rpms)
+        self.run_in_guest("yum -y install %s"%rpms)
+        return  self.run_in_guest("rpm -q %s"%rpms)==0
+
     def auth_root (self):
        return {'Username':self.plc_spec['PLC_ROOT_USER'],
                'AuthMethod':'password',
@@ -339,6 +345,23 @@ class TestPlc:
         self.display_pass (2)
         return True
 
+    def export (self):
+        "print cut'n paste-able stuff to export env variables to your shell"
+        # these work but the shell prompt does not get displayed..
+        command1="ssh %s vserver %s enter"%(self.plc_spec['host_box'],self.plc_spec['vservername'])
+        command2="ssh root@%s %s"%(socket.gethostname(),command1)
+        # guess local domain from hostname
+        domain=socket.gethostname().split('.',1)[1]
+        fqdn="%s.%s"%(self.plc_spec['host_box'],domain)
+        print "export BUILD=%s"%self.options.buildname
+        print "export PLCHOST=%s"%fqdn
+        print "export GUEST=%s"%self.plc_spec['vservername']
+        # find hostname of first node
+        (hostname,qemubox) = self.all_node_infos()[0]
+        print "export KVMHOST=%s.%s"%(qemubox,domain)
+        print "export NODE=%s"%(hostname)
+        return True
+
     # entry point
     always_display_keys=['PLC_WWW_HOST','nodes','sites',]
     def display_pass (self,passno):
@@ -448,36 +471,36 @@ class TestPlc:
         now=int(time.time())
         return utils.system(self.test_ssh.actual_command("echo %d > /vservers/%s.timestamp"%(now,self.vservername)))==0
         
-    def local_pre (self):
-        "run site-dependant pre-test script as defined in LocalTestResources"
-        from LocalTestResources import local_resources
-        return local_resources.step_pre(self)
-    def local_post (self):
-        "run site-dependant post-test script as defined in LocalTestResources"
-        from LocalTestResources import local_resources
-        return local_resources.step_post(self)
-    def local_list (self):
-        "run site-dependant list script as defined in LocalTestResources"
-        from LocalTestResources import local_resources
-        return local_resources.step_list(self)
-    def local_rel (self):
-        "run site-dependant release script as defined in LocalTestResources"
-        from LocalTestResources import local_resources
-        return local_resources.step_release(self)
-    def local_rel_plc (self):
-        "run site-dependant release script as defined in LocalTestResources"
-        from LocalTestResources import local_resources
-        return local_resources.step_release_plc(self)
-    def local_rel_qemu (self):
-        "run site-dependant release script as defined in LocalTestResources"
-        from LocalTestResources import local_resources
-        return local_resources.step_release_qemu(self)
+#    def local_pre (self):
+#        "run site-dependant pre-test script as defined in LocalTestResources"
+#        from LocalTestResources import local_resources
+#        return local_resources.step_pre(self)
+# 
+#    def local_post (self):
+#        "run site-dependant post-test script as defined in LocalTestResources"
+#        from LocalTestResources import local_resources
+#        return local_resources.step_post(self)
+# 
+#    def local_list (self):
+#        "run site-dependant list script as defined in LocalTestResources"
+#        from LocalTestResources import local_resources
+#        return local_resources.step_list(self)
+# 
+#    def local_rel (self):
+#        "run site-dependant release script as defined in LocalTestResources"
+#        from LocalTestResources import local_resources
+#        return local_resources.step_release(self)
+# 
+#    def local_rel_plc (self):
+#        "run site-dependant release script as defined in LocalTestResources"
+#        from LocalTestResources import local_resources
+#        return local_resources.step_release_plc(self)
+# 
+#    def local_rel_qemu (self):
+#        "run site-dependant release script as defined in LocalTestResources"
+#        from LocalTestResources import local_resources
+#        return local_resources.step_release_qemu(self)
+# 
     def vs_delete(self):
         "vserver delete the test myplc"
         self.run_in_host("vserver --silent %s delete"%self.vservername)
@@ -549,8 +572,7 @@ class TestPlc:
         pkgs_list.append ("noderepo-%s"%nodefamily)
         pkgs_list.append ("bootstrapfs-%s-plain"%nodefamily)
         pkgs_string=" ".join(pkgs_list)
-        self.run_in_guest("yum -y install %s"%pkgs_string)
-        return self.run_in_guest("rpm -q %s"%pkgs_string)==0
+        return self.yum_install (pkgs_list)
 
     ### 
     def plc_configure(self):
@@ -1105,11 +1127,23 @@ class TestPlc:
 
     ### sfa_install_rpm
     def sfa_install(self):
-        "yum install sfa, sfa-plc and sfa-client"
-        # ignore yum retcod
-        self.run_in_guest("yum -y install sfa sfa-client sfa-plc sfa-sfatables")
-        return  self.run_in_guest("rpm -q sfa sfa-client sfa-plc sfa-sfatables")==0
+        "yum install sfa"
+        return self.yum_install ("sfa")
         
+    ### sfa_install_rpm
+    def sfa_plc_install(self):
+        "yum install sfa-plc"
+        return self.yum_install("sfa-plc")
+        
+    ### sfa_install_rpm
+    def sfa_client_install(self):
+        "yum install sfa-client"
+        return self.yum_install("sfa-client")
+        
+    ### sfa_install_rpm
+    def sfa_tables_install(self):
+        "yum install sfa-client"
+        return self.yum_install ("sfa-sfatables")
 
     def sfa_dbclean(self):
         "thoroughly wipes off the SFA database"
@@ -1198,12 +1232,14 @@ class TestPlc:
                     'SFA_REGISTRY_HOST',
                     'SFA_AGGREGATE_HOST',
                      'SFA_SM_HOST',
+                    'SFA_PLC_URL',
                      'SFA_PLC_USER',
                      'SFA_PLC_PASSWORD',
-                     'SFA_PLC_DB_HOST',
-                     'SFA_PLC_DB_USER',
-                     'SFA_PLC_DB_PASSWORD',
-                    'SFA_PLC_URL',
+                     'SFA_DB_HOST',
+                     'SFA_DB_USER',
+                     'SFA_DB_PASSWORD',
+                     # should be tmp
+                     'SFA_DB_NAME',
                      ]:
             fileconf.write ('e %s\n%s\n'%(var,self.plc_spec['sfa'][var]))
         # the way plc_config handles booleans just sucks..
@@ -1453,6 +1489,9 @@ class TestPlc:
 
         utils.header('Database restored from ' + dump)
 
+    def standby_1_through_20(self):
+        """convenience function to wait for a specified number of minutes"""
+        pass
     @standby_generic 
     def standby_1(): pass
     @standby_generic