Add step chek_initscripts.
authorMarc Fiuczynski <mef@cs.princeton.edu>
Fri, 15 Feb 2008 12:01:12 +0000 (12:01 +0000)
committerMarc Fiuczynski <mef@cs.princeton.edu>
Fri, 15 Feb 2008 12:01:12 +0000 (12:01 +0000)
Redirect the output of  node's steps  to a specific log file

system/TestMain.py
system/TestNode.py
system/TestPlc.py
system/TestSlice.py

index 2748150..77c939f 100755 (executable)
@@ -23,7 +23,7 @@ class TestMain:
                      'bootcd', 'nodegroups', 
                      'kill_all_qemus', 'start_nodes', 
                      'standby_4', 'nodes_booted',
-                     'standby_6','nodes_ssh', 'check_slices',
+                     'standby_6','nodes_ssh', 'check_slices','check_initscripts',
                      'check_tcp',
                      'kill_qemus', ]
     other_steps = [ 'fresh_install', 'stop', 
index f4a55dc..e10d4a3 100644 (file)
@@ -110,10 +110,12 @@ class TestNode:
             utils.header ('Transferring configuration files for node %s into %s '%(hostname,host_box))
             cleandir_command="ssh root@%s rm -rf %s"%(host_box, dest_dir)
             createdir_command = "ssh root@%s mkdir -p  %s"%(host_box, dest_dir)
-            utils.system(cleandir_command)
-            utils.system(createdir_command)
+            createlog_command = "ssh root@%s touch  %s/%s.log "%(host_box, dest_dir,hostname)
+            self.test_plc.run_in_host(cleandir_command)
+            self.test_plc.run_in_host(createdir_command)
+            self.test_plc.run_in_host(createlog_command)
             scp_command = "scp -r %s/qemu-%s/* root@%s:/root/%s"%(path,hostname,host_box,dest_dir)
-            utils.system(scp_command)
+            self.test_plc.run_in_host(scp_command)
 
     def create_boot_cd(self,path):
         model=self.node_spec['node_fields']['model']
@@ -126,16 +128,16 @@ class TestNode:
         if  model.find("qemu") >= 0:
             clean_dir="rm -rf %s/qemu-%s"%(path,hostname)
             mkdir_command="mkdir -p %s/qemu-%s"%(path,hostname)
-            utils.system(clean_dir)
-            utils.system(mkdir_command)
+            self.test_plc.run_in_host(clean_dir)
+            self.test_plc.run_in_host(mkdir_command)
             copy_command="cp -r  %s/template-Qemu/* %s/qemu-%s"%(path,path,hostname)
-            utils.system(copy_command)
+            self.test_plc.run_in_host(copy_command)
             utils.header('Creating boot medium for node %s'%hostname)
             file=open(path+'/qemu-'+hostname+'/boot_file.iso','w')
         else:
             nodepath="%s/real-%s"%(path,hostname)
-            utils.system("rm -rf %s"%nodepath)
-            utils.system("mkdir %s"%nodepath)
+            self.test_plc.run_in_host("rm -rf %s"%nodepath)
+            self.test_plc.run_in_host("mkdir %s"%nodepath)
             file=open("%s/%s"%(nodepath,"/boot_file.iso"),'w')
 
         file.write(base64.b64decode(encoded))
@@ -158,9 +160,12 @@ class TestNode:
         path=options.path
         display=options.display
         dest_dir="qemu-%s"%(hostname)
-        utils.header('Starting qemu for node %s '%(hostname))
-        self.test_plc.run_in_host("ssh root@%s ~/%s/%s/env-qemu start"%(host_box, path, dest_dir ))
-        self.test_plc.run_in_host("ssh  root@%s DISPLAY=%s  ~/%s/start-qemu-node %s & "%( host_box, display, dest_dir, dest_dir))
+        utils.header('Starting qemu for node %s and Redirect logs to /%s/%s.log '
+                     %(hostname, dest_dir, hostname))
+        self.test_plc.run_in_host("ssh root@%s ~/%s/%s/env-qemu start >> ~/%s/%s.log "
+                                  %(host_box, path, dest_dir, dest_dir, hostname ))
+        self.test_plc.run_in_host("ssh  root@%s DISPLAY=%s  ~/%s/start-qemu-node %s >> ~/%s/%s.log & "
+                                  %( host_box, display, dest_dir, dest_dir, dest_dir, hostname))
         
     def kill_qemu (self):
         hostname = self.name()
index 5381444..db196f3 100644 (file)
@@ -492,7 +492,7 @@ class TestPlc:
         
     def nodes_ssh(self, options):
         return  self.do_check_nodesSsh(minutes=2)
-            
+    
     def bootcd (self, options):
         for site_spec in self.plc_spec['sites']:
             test_site = TestSite (self,site_spec)
@@ -500,7 +500,20 @@ class TestPlc:
                 test_node=TestNode (self,test_site,node_spec)
                 test_node.create_boot_cd(options.path)
         return True
-                
+
+    def do_check_intiscripts(self):
+           for site_spec in self.plc_spec['sites']:
+                   test_site = TestSite (self,site_spec)
+                   for slice_spec in self.plc_spec['slices']:
+                           test_slice=TestSlice (self,test_site,slice_spec)
+                           init_status=test_slice.get_initscript()
+                           if (not init_status):
+                                   return False
+                   return init_status
+           
+    def check_initscripts(self, options):
+           return self.do_check_intiscripts()
+                   
     def initscripts (self, options):
         for initscript in self.plc_spec['initscripts']:
             utils.show_spec('Adding Initscript in plc %s'%self.plc_spec['name'],initscript)
index 2ae9339..73c047e 100644 (file)
@@ -79,6 +79,19 @@ class TestSlice:
 
         return (found,remote_privatekey)
 
+    def get_initscript(self):
+        (found,remote_privatekey)=self.locate_key(self.slice_spec)
+        if not found :
+            raise Exception,"Cannot find a valid key for slice %s"%self.name()
+        for hostname in  self.slice_spec['nodenames']:
+            utils.header("Checking initiscript %s on the slice %s@%s"
+                         %(self.slice_spec['initscriptname'],self.name(),hostname))
+            init_file=self.test_plc.run_in_guest('ssh -i %s %s@%s ls -l /tmp/init* '%(remote_privatekey,self.name(),hostname))
+            if ( init_file):
+                return False
+            
+        return True
+    
     def do_check_slice(self,options):
         bool=True
         self.clear_known_hosts()