From: Tony Mack Date: Tue, 15 Jan 2008 21:48:35 +0000 (+0000) Subject: method for booting nodes X-Git-Tag: 2008-02-11-last-vmware-support~169 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=f24fb0acc1345963060580e8c1329ec334e132eb;p=tests.git method for booting nodes --- diff --git a/qaapi/qa/modules/plc/boot_node.py b/qaapi/qa/modules/plc/boot_node.py new file mode 100644 index 0000000..cae230c --- /dev/null +++ b/qaapi/qa/modules/plc/boot_node.py @@ -0,0 +1,47 @@ +import os,sys +import base64 +from qa.Test import Test +from qa import utils + +class boot_node(Test): + + def call(self, hostname, disk_size = "500M"): + api = self.config.api + auth = self.config.auth + + # validate hostname + nodes = api.GetNodes(auth, [hostname], ['hostname']) + if not nodes: + raise Exception, "No such node %s" + + bootimage = api.GetBootMedium(auth, hostname, 'node-iso', '') + bootimage_path = '/tmp/%(hostname)s-bootcd.iso' % locals() + + if self.config.verbose: + utils.header("Creating bootcd for %(hostname)s at %(bootimage_path)s" % locals()) + # Create a temporary bootcd file + file = open(bootimage_path, 'w') + file.write(base64.b64decode(bootimage)) + file.close() + + # Create a temporary disk image + diskimage_path = "/tmp/%(hostname)s-hda.img" % locals() + qemu_img_cmd = "qemu-img create %(diskimage_path)s %(disk_size)s" % locals() + (stdin, stdout, stderr) = os.popen3(qemu_img_cmd) + self.errors = stderr.readlines() + if self.errors: + raise Exception, "Unable to create disk image\n" + \ + "\n".join(self.errors) + + if self.config.verbose: + utils.header("Booting %(hostname)s" % locals()) + # Attempt to boot this node image + bootcmd = "qemu -kernel-kqemu -hda %(diskimage_path)s -cdrom %(bootimage_path)s" % \ + locals() + (stdin, stdout, stderr) = os.popen3(bootcmd) + self.errors = stderr.readlines() + if self.errors: + raise Exception, "Unable to boot node image\n" + \ + "\n".join(self.errors) + + return True