no more lxc-enter-namespace - use ssh
[tests.git] / qaapi / qa / tests / boot_node.py
index 3d2f321..9567a29 100644 (file)
@@ -32,16 +32,16 @@ class boot_node(Test):
         node = nodes[0]
         boot_state = node['boot_state']
         if True or self.config.verbose:
-            utils.header("%(hostname)s boot_state is %(boot_state)s" % locals(), False) 
+            utils.header("%(hostname)s boot_state is %(boot_state)s" % locals(), False, self.config.logfile
             
         if boot_state in ['boot']:
             self.exit = True
 
        if self.config.verbose:
            if boot_state in ['boot']:
-               utils.header("%(hostname)s correctly installed and booted" % locals(), False)
+               utils.header("%(hostname)s correctly installed and booted" % locals(), False, self.config.logfile)
            else:
-               utils.header("%(hostname)s not fully booted" % locals(), False)
+               utils.header("%(hostname)s not fully booted" % locals(), False, self.config.logfile)
         self.boot_state = boot_state
         return self.exit
         
@@ -67,7 +67,7 @@ class boot_node(Test):
             # for now just print it out
            for line in lines:
                 print line
-               utils.header(line) 
+               utils.header(line, logfile = self.config.logfile
             # should be parsing for special strings that indicate whether
             # we've reached a particular state within the boot sequence
 
@@ -78,6 +78,8 @@ class boot_node(Test):
         
        # Get this nodes configuration 
        node = self.config.get_node(hostname)
+       node.rotate_logfile()
+
        # Which plc does this node talk to 
        plc = self.config.get_plc(plc_name)
         api = plc.config.api
@@ -89,12 +91,16 @@ class boot_node(Test):
        bootimage_filename = "%(hostname)s-bootcd.iso" % locals()
        diskimage_filename = "%(hostname)s-hda.img" % locals() 
        bootimage = "%(homedir)s/%(bootimage_filename)s" % locals()
-       diskimage = "%(homedir)s/%(diskimage_filename)s" % locals() 
-       diskimage_path = "/%(path)s/%(diskimage_filename)s" % locals() 
+       diskimage = "%(homedir)s/%(diskimage_filename)s" % locals()
+       print bootimage
+       print diskimage 
+       diskimage_path = "/%(path)s/%(diskimage)s" % locals() 
         bootimage_tmppath = "%(tmpdir)s/%(bootimage_filename)s" % locals()
-       bootimage_path = "%(path)s/%(bootimage_filename)s" % locals()
+       bootimage_path = "/%(path)s/%(bootimage)s" % locals()
        remote_bootimage_path = "%(homedir)s/%(bootimage_filename)s" % locals() 
-        
+       print bootimage_path
+       print diskimage_path
+       print remote_bootimage_path 
        # wait up to 30 minutes for a node to boot and install itself correctly
         self.hostname = hostname
         self.totaltime = 60*60*wait
@@ -108,12 +114,12 @@ class boot_node(Test):
        # try reinstalling the node if it is in debug state
        if node['boot_state'] in ['dbg']:
            if self.config.verbose:
-               utils.header("%(hostname)s is in debug state. Attempting a re-install" % locals())
-           api.UpdateNode(auth, node['node_id'], {'boot_state': 'rins'}) 
+               utils.header("%(hostname)s is in debug state. Attempting a re-install" % locals(), logfile = self.config.logfile)
+           api.UpdateNode(auth, node['hostname'], {'boot_state': 'rins'}) 
        
        # Create boot image
        if self.config.verbose:
-            utils.header("Creating bootcd for %(hostname)s at %(bootimage_path)s" % locals())  
+            utils.header("Creating bootcd for %(hostname)s at %(bootimage_path)s" % locals(), logfile = self.config.logfile)   
        nodeimage = api.GetBootMedium(auth, hostname, image_type, '', ['serial'])
        fp = open(bootimage_tmppath, 'w')
        fp.write(base64.b64decode(nodeimage))
@@ -122,16 +128,21 @@ class boot_node(Test):
        # Move the boot image to the nodes home directory
        node.host_commands("mkdir -p %(homedir)s" % locals())
        node.scp_to_host(bootimage_tmppath, "%(remote_bootimage_path)s" % locals())
+
+       # If node is vm (qemu) try installing kqemu
+       #node.host_commands("yum -y install kqemu", False)
+       #node.host_commands("modprobe kqemu", False)
        
        # Create a temporary disk image if it doesnt already exist or we are reinstalling
        img_check_cmd =  "ls -ld %(diskimage)s" % locals()
        (status, output) = node.host_commands(img_check_cmd, False)
        if status != 0 or node['boot_state'] in ['rins', 'inst']:
-           qemu_img_cmd = "qemu-img create -f qcow2 %(diskimage)s %(disk_size)s" % locals()
+           qemu_img_cmd = "/usr/bin/qemu-img create -f qcow2 %(diskimage)s %(disk_size)s" % locals()
            node.host_commands(qemu_img_cmd)
 
+       
        if self.config.verbose:
-            utils.header("Booting %(hostname)s" % locals())
+            utils.header("Booting %(hostname)s" % locals(), logfile = self.config.logfile)
 
        # Attempt to boot this node image
 
@@ -145,7 +156,7 @@ class boot_node(Test):
         ramsize=1024
 
         # always use the 64 bit version of qemu, as this will work on both 32 & 64 bit host kernels
-        bootcmd = "qemu-system-x86_64" 
+        bootcmd = "/usr/bin/qemu-system-x86_64" 
         # tell qemu to store its pid ina  file
         bootcmd = bootcmd + " -pidfile %(pidfile)s " % locals()
         # boot with ramsize memory
@@ -168,7 +179,7 @@ class boot_node(Test):
        bootcmd = bootcmd + " 2>&1 >> %s " % (node.logfile.filename)
         
        # kill any old qemu processes for this node
-       pid_cmd = "ps -elfy | grep qemu | grep %(hostname)s | awk '{print$3}'" % locals()
+       pid_cmd = "ps -elfy | grep qemu | grep -v grep | grep %(hostname)s | awk '{print$3}'" % locals()
        (status, output) = node.host_commands(pid_cmd)
        pids = " ".join(output.split("\n")).strip() 
        if pids:
@@ -176,6 +187,7 @@ class boot_node(Test):
            (status, output) = node.host_commands(kill_cmd)
        
        time.sleep(2)
+       
        # launch qemu
        (self.stdin, self.stdout, self.stderr) = node.host_popen3(bootcmd)
         
@@ -195,7 +207,7 @@ class boot_node(Test):
         # occured, or we've reached our totaltime out
         def catch(sig, frame):
             self.totaltime = self.totaltime -1
-           utils.header("beep %d\n" %self.totaltime, False)
+           utils.header("beep %d\n" %self.totaltime, False, logfile = self.config.logfile )
             total = self.totaltime
             if (total == 0) or \
                    (((total % 60)==0) and self.state_nanny()):