def _image2XMLhelper(self, image_xml, output_xmls, qemu=False): image2guestdir = self.basedir + "image2guest/" image = virtinst.ImageParser.parse_file(self.basedir + image_xml) if type(output_xmls) is not list: output_xmls = [output_xmls] conn = qemu and self.qemuconn or self.conn caps = qemu and self.qemucaps or self.caps gtype = qemu and "qemu" or "xen" for idx in range(len(output_xmls)): fname = output_xmls[idx] inst = virtinst.ImageInstaller(image, caps, boot_index=idx, conn=conn) utils.set_conn(conn) if inst.is_hvm(): g = utils.get_basic_fullyvirt_guest(typ=gtype) else: g = utils.get_basic_paravirt_guest() g.installer = inst g._prepare_install(None) actual_out = g.get_config_xml(install=False) expect_file = os.path.join(image2guestdir + fname) expect_out = utils.read_file(expect_file) expect_out = expect_out.replace("REPLACEME", os.getcwd()) utils.diff_compare(actual_out, expect_file, expect_out=expect_out) utils.reset_conn()
def _image2XMLhelper(self, image_xml, output_xmls): image2guestdir = self.basedir + "image2guest/" image = virtinst.ImageParser.parse_file(self.basedir + image_xml) if type(output_xmls) is not list: output_xmls = [output_xmls] for idx in range(len(output_xmls)): fname = output_xmls[idx] inst = virtinst.ImageInstaller(image, self.caps, boot_index=idx) if inst.is_hvm(): g = xmlconfig.get_basic_fullyvirt_guest() else: g = xmlconfig.get_basic_paravirt_guest() g.installer = inst g._prepare_install(None) expect_out = tests.read_file(image2guestdir + fname) expect_out = expect_out.replace("REPLACEME", os.getcwd()) tests.diff_compare(g.get_config_xml(install=False), image2guestdir + fname, expect_out=expect_out)
def start_install(name=None, ram=None, disks=None, uuid=None, extra=None, vcpus=None, profile_data=None, arch=None, no_gfx=False, fullvirt=False, bridge=None, virt_type=None, virt_auto_boot=None): #FIXME how to do a non-default connection #Can we drive off of virt-type? connection = None if (virt_type is None) or (virt_type == "auto"): connection = virtinst.util.default_connection() elif virt_type.lower()[0:3] == "xen": connection = "xen" else: connection = "qemu:///system" connection = libvirt.open(connection) capabilities = virtinst.CapabilitiesParser.parse( connection.getCapabilities()) image_arch = transform_arch(arch) image = ImageParser.Image() #dev api #image = ImageParser.Image(filename="") #FIXME, ImageParser should take in None image.name = name domain = ImageParser.Domain() domain.vcpu = vcpus domain.memory = ram image.domain = domain boot = ImageParser.Boot() boot.type = "hvm" #FIXME HARDCODED boot.loader = "hd" #FIXME HARDCODED boot.arch = image_arch domain.boots.append(boot) #FIXME Several issues. Single Disk, type is hardcoded #And there is no way to provision with access to "file" process_disk(image, boot, profile_data["file"], disks[0][0], "hda") #FIXME boot_index?? installer = virtinst.ImageInstaller(boot_index=0, image=image, capabilities=capabilities) guest = virtinst.FullVirtGuest(connection=connection, installer=installer, arch=image_arch) extra = extra.replace("&", "&") guest.extraargs = extra guest.set_name(name) guest.set_memory(ram) guest.set_vcpus(vcpus) if not no_gfx: guest.set_graphics("vnc") else: guest.set_graphics(False) if uuid is not None: guest.set_uuid(uuid) process_networks(domain, guest, profile_data, bridge) guest.start_install() return "use virt-manager or reconnect with virsh console %s" % name
def testImageInstaller(self): label = 'imageinstaller' inst_obj = virtinst.ImageInstaller(image=virtimage, capabilities=testcaps) #self._testArgs(inst_obj, virtinst.ImageInstaller, 'installer') self._testArgs(inst_obj, virtinst.ImageInstaller, label)
def testBadArch(self): """Makes sure we sanitize i386->i686""" image = virtinst.ImageParser.parse_file(self.basedir + "image-bad-arch.xml") virtinst.ImageInstaller(image, self.caps, 0) self.assertTrue(True)