Esempio n. 1
0
    def _image2XMLhelper(self, image_xml, output_xmls, qemu=False):
        image2guestdir = self.basedir + "image2guest/"
        image = virtimage.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
        gtype = qemu and "qemu" or "xen"

        for idx in range(len(output_xmls)):
            fname = output_xmls[idx]
            inst = virtimage.ImageInstaller(conn, image, boot_index=idx)
            capsguest, capsdomain = inst.get_caps_guest()
            if capsguest.os_type == "hvm":
                g = utils.get_basic_fullyvirt_guest(typ=gtype)
            else:
                g = utils.get_basic_paravirt_guest()

            utils.set_conn(conn)
            g.os.os_type = capsguest.os_type
            g.type = capsdomain.hypervisor_type
            g.os.arch = capsguest.arch

            g.installer = inst
            # pylint: disable=unpacking-non-sequence
            ignore, actual_out = g.start_install(return_xml=True, dry=True)

            actual_out = g.get_install_xml(install=False)
            expect_file = os.path.join(image2guestdir + fname)

            actual_out = actual_out.replace(os.getcwd(), "/tmp")
            utils.diff_compare(actual_out, expect_file)

            utils.reset_conn()
Esempio n. 2
0
    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_xml_config(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()
Esempio n. 3
0
    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_xml_config(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()
Esempio n. 4
0
    def testF10(self):
        utils.set_conn(_plainkvm)
        i = utils.make_pxe_installer()
        g = utils.get_basic_fullyvirt_guest("kvm", installer=i)

        g.os_variant = "fedora10"
        g.add_device(utils.get_filedisk())
        g.add_device(utils.get_blkdisk())
        g.add_device(utils.get_virtual_network())
        self._compare(g, "install-f10", True)
Esempio n. 5
0
    def testF10(self):
        utils.set_conn(_plainkvm)
        i = utils.make_pxe_installer()
        g = utils.get_basic_fullyvirt_guest("kvm", installer=i)

        g.os_variant = "fedora10"
        g.add_device(utils.get_filedisk())
        g.add_device(utils.get_blkdisk())
        g.add_device(utils.get_virtual_network())
        self._compare(g, "install-f10", True)
Esempio n. 6
0
    def testF11Xen(self):
        utils.set_conn(_plainxen)
        i = utils.make_distro_installer()
        g = utils.get_basic_fullyvirt_guest("xen", installer=i)

        g.os_variant = "fedora11"
        g.installer.cdrom = True
        g.add_device(utils.get_floppy())
        g.add_device(utils.get_filedisk())
        g.add_device(utils.get_blkdisk())
        g.add_device(utils.get_virtual_network())
        self._compare(g, "install-f11-xen", False)
Esempio n. 7
0
    def testF11Xen(self):
        utils.set_conn(_plainxen)
        i = utils.make_distro_installer()
        g = utils.get_basic_fullyvirt_guest("xen", installer=i)

        g.os_variant = "fedora11"
        g.installer.cdrom = True
        g.add_device(utils.get_floppy())
        g.add_device(utils.get_filedisk())
        g.add_device(utils.get_blkdisk())
        g.add_device(utils.get_virtual_network())
        self._compare(g, "install-f11-xen", False)
Esempio n. 8
0
    def testF11Qemu(self):
        utils.set_conn(_plainkvm)
        i = utils.make_distro_installer(gtype="qemu")
        g = utils.get_basic_fullyvirt_guest("qemu", installer=i)

        g.os_type = "linux"
        g.os_variant = "fedora11"
        g.installer.cdrom = True
        g.add_device(utils.get_floppy())
        g.add_device(utils.get_filedisk())
        g.add_device(utils.get_blkdisk())
        g.add_device(utils.get_virtual_network())
        self._compare(g, "install-f11-qemu", False)
Esempio n. 9
0
    def testFullKVMRHEL6(self):
        utils.set_conn(_plainkvm)
        i = utils.make_distro_installer(
                                  location="tests/cli-test-xml/fakerhel6tree")
        g = utils.get_basic_fullyvirt_guest("kvm", installer=i)
        g.add_device(utils.get_floppy())
        g.add_device(utils.get_filedisk("/dev/default-pool/rhel6.img", fake=False))
        g.add_device(utils.get_blkdisk())
        g.add_device(utils.get_virtual_network())
        g.add_device(VirtualAudio(g.conn))
        g.add_device(VirtualVideoDevice(g.conn))
        g.os_autodetect = True

        self._testInstall(g, "rhel6-kvm-stage1", "rhel6-kvm-stage2")
Esempio n. 10
0
    def testCpuset(self):
        normaltest = utils.open_testdefault()
        utils.set_conn(normaltest)
        g = utils.get_basic_fullyvirt_guest()

        # Cpuset
        cpustr = virtinst.DomainNumatune.generate_cpuset(g.conn, g.memory)
        g.cpuset = cpustr
        g.vcpus = 7

        g.cpu.model = "footest"
        g.cpu.vendor = "Intel"
        g.cpu.match = "minimum"

        g.cpu.threads = "2"
        g.cpu.sockets = "4"
        g.cpu.cores = "5"

        g.cpu.add_feature("x2apic", "force")
        g.cpu.add_feature("lahf_lm", "forbid")

        self._compare(g, "boot-cpuset", False)

        # Test CPU topology determining
        cpu = virtinst.CPU(g.conn)
        cpu.sockets = "2"
        cpu.set_topology_defaults(6)
        self.assertEquals([cpu.sockets, cpu.cores, cpu.threads], [2, 3, 1])

        cpu = virtinst.CPU(g.conn)
        cpu.cores = "4"
        cpu.set_topology_defaults(9)
        self.assertEquals([cpu.sockets, cpu.cores, cpu.threads], [2, 4, 1])

        cpu = virtinst.CPU(g.conn)
        cpu.threads = "3"
        cpu.set_topology_defaults(14)
        self.assertEquals([cpu.sockets, cpu.cores, cpu.threads], [4, 1, 3])

        cpu = virtinst.CPU(g.conn)
        cpu.sockets = 5
        cpu.cores = 2
        self.assertEquals(cpu.vcpus_from_topology(), 10)

        cpu = virtinst.CPU(g.conn)
        self.assertEquals(cpu.vcpus_from_topology(), 1)
Esempio n. 11
0
    def testFullKVMRHEL6(self):
        utils.set_conn(_plainkvm)
        i = utils.make_distro_installer(
            location="tests/cli-test-xml/fakerhel6tree")
        g = utils.get_basic_fullyvirt_guest("kvm", installer=i)
        g.add_device(utils.get_floppy())
        g.add_device(
            utils.get_filedisk("/dev/default-pool/rhel6.img", fake=False))
        g.add_device(utils.get_blkdisk())
        g.add_device(utils.get_virtual_network())
        g.add_device(VirtualAudio(g.conn))
        g.add_device(VirtualVideoDevice(g.conn))

        self._testInstall(g,
                          "rhel6-kvm-stage1",
                          "rhel6-kvm-stage2",
                          detect_distro=True)
Esempio n. 12
0
    def testInstallWindowsXenNew(self):
        def make_guest():
            g = utils.get_basic_fullyvirt_guest("xen")
            g.os_variant = "winxp"
            g.add_device(utils.get_filedisk())
            g.add_device(utils.get_blkdisk())
            g.add_device(utils.get_virtual_network())
            g.add_device(VirtualAudio(g.conn))
            return g

        utils.set_conn(utils.open_plainxen(connver=3000001))
        g = make_guest()
        self._compare(g, "install-windowsxp-xenold", True)

        utils.set_conn(utils.open_plainxen(connver=3100000))
        g = make_guest()
        self._compare(g, "install-windowsxp-xennew", True)
Esempio n. 13
0
    def testCpuset(self):
        normaltest = libvirt.open("test:///default")
        utils.set_conn(normaltest)
        g = utils.get_basic_fullyvirt_guest()

        # Cpuset
        cpustr = g.generate_cpuset(g.conn, g.memory)
        g.cpuset = cpustr
        g.maxvcpus = 7

        g.cpu.model = "footest"
        g.cpu.vendor = "Intel"
        g.cpu.match = "minimum"

        g.cpu.threads = "2"
        g.cpu.sockets = "4"
        g.cpu.cores = "5"

        g.cpu.add_feature("x2apic", "force")
        g.cpu.add_feature("lahf_lm", "forbid")

        self._compare(g, "boot-cpuset", False)

        # Test CPU topology determining
        cpu = virtinst.CPU(g.conn)
        cpu.sockets = "2"
        cpu.set_topology_defaults(6)
        self.assertEquals([cpu.sockets, cpu.cores, cpu.threads], [2, 3, 1])

        cpu = virtinst.CPU(g.conn)
        cpu.cores = "4"
        cpu.set_topology_defaults(9)
        self.assertEquals([cpu.sockets, cpu.cores, cpu.threads], [2, 4, 1])

        cpu = virtinst.CPU(g.conn)
        cpu.threads = "3"
        cpu.set_topology_defaults(14)
        self.assertEquals([cpu.sockets, cpu.cores, cpu.threads], [4, 1, 3])

        cpu = virtinst.CPU(g.conn)
        cpu.sockets = 5
        cpu.cores = 2
        self.assertEquals(cpu.vcpus_from_topology(), 10)

        cpu = virtinst.CPU(g.conn)
        self.assertEquals(cpu.vcpus_from_topology(), 1)
Esempio n. 14
0
    def testInstallWindowsXenNew(self):
        def make_guest():
            g = utils.get_basic_fullyvirt_guest("xen")
            g.os_variant = "winxp"
            g.add_device(utils.get_filedisk())
            g.add_device(utils.get_blkdisk())
            g.add_device(utils.get_virtual_network())
            g.add_device(VirtualAudio(g.conn))
            return g

        utils.set_conn(utils.open_plainxen(connver=3000001))
        g = make_guest()
        self._compare(g, "install-windowsxp-xenold", True)

        utils.set_conn(utils.open_plainxen(connver=3100000))
        g = make_guest()
        self._compare(g, "install-windowsxp-xennew", True)
Esempio n. 15
0
    def testQEMUDriverName(self):
        utils.set_conn(_plainkvm)
        g = utils.get_basic_fullyvirt_guest()
        g.add_device(utils.get_blkdisk())
        self._compare(g, "misc-qemu-driver-name", True)

        g = utils.get_basic_fullyvirt_guest()
        g.add_device(utils.get_filedisk())
        g.add_device(utils.get_blkdisk("/iscsi-pool/diskvol1"))
        self._compare(g, "misc-qemu-driver-type", True)

        g = utils.get_basic_fullyvirt_guest()
        g.add_device(utils.get_filedisk("/default-pool/iso-vol"))
        self._compare(g, "misc-qemu-iso-disk", True)

        g = utils.get_basic_fullyvirt_guest()
        g.add_device(utils.get_filedisk("/default-pool/iso-vol"))
        g.get_devices("disk")[0].driver_type = "qcow2"
        self._compare(g, "misc-qemu-driver-overwrite", True)
Esempio n. 16
0
    def testQEMUDriverName(self):
        utils.set_conn(_plainkvm)
        g = utils.get_basic_fullyvirt_guest()
        g.add_device(utils.get_blkdisk())
        self._compare(g, "misc-qemu-driver-name", True)

        g = utils.get_basic_fullyvirt_guest()
        g.add_device(utils.get_filedisk())
        g.add_device(utils.get_blkdisk("/iscsi-pool/diskvol1"))
        self._compare(g, "misc-qemu-driver-type", True)

        g = utils.get_basic_fullyvirt_guest()
        g.add_device(utils.get_filedisk("/dev/default-pool/iso-vol"))
        self._compare(g, "misc-qemu-iso-disk", True)

        g = utils.get_basic_fullyvirt_guest()
        g.add_device(utils.get_filedisk("/dev/default-pool/iso-vol"))
        g.get_devices("disk")[0].driver_type = "qcow2"
        self._compare(g, "misc-qemu-driver-overwrite", True)
Esempio n. 17
0
    def testF11AC97(self):
        def build_guest():
            i = utils.make_distro_installer()
            g = utils.get_basic_fullyvirt_guest("kvm", installer=i)

            g.os_variant = "fedora11"
            g.installer.cdrom = True
            g.add_device(utils.get_floppy())
            g.add_device(utils.get_filedisk())
            g.add_device(utils.get_blkdisk())
            g.add_device(utils.get_virtual_network())
            g.add_device(VirtualAudio(g.conn))
            return g

        utils.set_conn(utils.open_plainkvm(connver=11000))
        g = build_guest()
        self._compare(g, "install-f11-ac97", False)

        utils.set_conn(utils.open_plainkvm(libver=5000))
        g = build_guest()
        self._compare(g, "install-f11-noac97", False)

        utils.set_conn(utils.open_plainkvm(libver=7000, connver=7000))
        g = build_guest()
        self._compare(g, "install-f11-noac97", False)
Esempio n. 18
0
    def testF11AC97(self):
        def build_guest():
            i = utils.make_distro_installer(gtype="kvm")
            g = utils.get_basic_fullyvirt_guest("kvm", installer=i)

            g.os_type = "linux"
            g.os_variant = "fedora11"
            g.installer.cdrom = True
            g.add_device(utils.get_floppy())
            g.add_device(utils.get_filedisk())
            g.add_device(utils.get_blkdisk())
            g.add_device(utils.get_virtual_network())
            g.add_device(VirtualAudio())
            return g

        utils.set_conn(utils.open_plainkvm(connver=11000))
        g = build_guest()
        self._compare(g, "install-f11-ac97", False)

        oldver = libvirt.getVersion
        try:
            utils.set_conn(utils.open_plainkvm(libver=5000))
            g = build_guest()
            self._compare(g, "install-f11-noac97", False)
        finally:
            libvirt.getVersion = oldver

        utils.set_conn(utils.open_plainkvm(connver=10000))
        g = build_guest()
        self._compare(g, "install-f11-noac97", False)
Esempio n. 19
0
    def testF11AC97(self):
        def build_guest():
            i = utils.make_distro_installer()
            g = utils.get_basic_fullyvirt_guest("kvm", installer=i)

            g.os_type = "linux"
            g.os_variant = "fedora11"
            g.installer.cdrom = True
            g.add_device(utils.get_floppy())
            g.add_device(utils.get_filedisk())
            g.add_device(utils.get_blkdisk())
            g.add_device(utils.get_virtual_network())
            g.add_device(VirtualAudio(g.conn))
            return g

        utils.set_conn(utils.open_plainkvm(connver=11000))
        g = build_guest()
        self._compare(g, "install-f11-ac97", False)

        utils.set_conn(utils.open_plainkvm(libver=5000))
        g = build_guest()
        self._compare(g, "install-f11-noac97", False)

        utils.set_conn(utils.open_plainkvm(connver=10000))
        g = build_guest()
        self._compare(g, "install-f11-noac97", False)
Esempio n. 20
0
    def testOSDeviceDefaultChange(self):
        """
        Make sure device defaults are properly changed if we change OS
        distro/variant mid process
        """
        utils.set_conn(_plainkvm)

        i = utils.make_distro_installer(gtype="kvm")
        g = utils.get_basic_fullyvirt_guest("kvm", installer=i)

        do_install = False
        g.installer.cdrom = True
        g.add_device(utils.get_floppy())
        g.add_device(utils.get_filedisk())
        g.add_device(utils.get_blkdisk())
        g.add_device(utils.get_virtual_network())

        # Call get_xml_config sets first round of defaults w/o os_variant set
        g.get_xml_config(do_install)

        g.os_variant = "fedora11"
        self._compare(g, "install-f11", do_install)
Esempio n. 21
0
    def testOSDeviceDefaultChange(self):
        """
        Make sure device defaults are properly changed if we change OS
        distro/variant mid process
        """
        conn = utils.open_plainkvm(connver=12005)
        utils.set_conn(conn)

        i = utils.make_distro_installer()
        g = utils.get_basic_fullyvirt_guest("kvm", installer=i)

        do_install = False
        g.installer.cdrom = True
        g.add_device(utils.get_floppy())
        g.add_device(utils.get_filedisk())
        g.add_device(utils.get_blkdisk())
        g.add_device(utils.get_virtual_network())
        g.add_device(VirtualAudio(g.conn))

        # Call get_xml_config sets first round of defaults w/o os_variant set
        g.get_install_xml(do_install)

        g.os_variant = "fedora11"
        self._compare(g, "install-f11-norheldefaults", do_install)

        try:
            virtinst.stable_defaults = True
            origemu = g.emulator
            g.emulator = "/usr/libexec/qemu-kvm"
            g.conn._support_cache = {}
            self._compare(g, "install-f11-rheldefaults", do_install)
            g.emulator = origemu
            g.conn._support_cache = {}
        finally:
            virtinst.stable_defaults = False

        # Verify main guest wasn't polluted
        self._compare(g, "install-f11-norheldefaults", do_install)
Esempio n. 22
0
    def testOSDeviceDefaultChange(self):
        """
        Make sure device defaults are properly changed if we change OS
        distro/variant mid process
        """
        conn = utils.open_plainkvm(connver=12005)
        utils.set_conn(conn)

        i = utils.make_distro_installer()
        g = utils.get_basic_fullyvirt_guest("kvm", installer=i)

        do_install = False
        g.installer.cdrom = True
        g.add_device(utils.get_floppy())
        g.add_device(utils.get_filedisk())
        g.add_device(utils.get_blkdisk())
        g.add_device(utils.get_virtual_network())
        g.add_device(VirtualAudio(g.conn))

        # Call get_xml_config sets first round of defaults w/o os_variant set
        g.get_install_xml(do_install)

        g.os_variant = "fedora11"
        self._compare(g, "install-f11-norheldefaults", do_install)

        try:
            virtinst.enable_rhel_defaults = True
            origemu = g.emulator
            g.emulator = "/usr/libexec/qemu-kvm"
            g.conn._support_cache = {}
            self._compare(g, "install-f11-rheldefaults", do_install)
            g.emulator = origemu
            g.conn._support_cache = {}
        finally:
            virtinst.enable_rhel_defaults = False

        # Verify main guest wasn't polluted
        self._compare(g, "install-f11-norheldefaults", do_install)
Esempio n. 23
0
    def testFullKVMRHEL6(self):
        utils.set_conn(_plainkvm)
        i = utils.make_distro_installer(
                                  location="tests/cli-test-xml/fakerhel6tree",
                                  gtype="kvm")
        g = utils.get_basic_fullyvirt_guest("kvm", installer=i)
        g.add_device(utils.get_floppy())
        g.add_device(utils.get_filedisk("/default-pool/rhel6.img"))
        g.add_device(utils.get_blkdisk())
        g.add_device(utils.get_virtual_network())
        g.add_device(VirtualAudio())
        g.add_device(VirtualVideoDevice(g.conn))
        g.os_autodetect = True

        # Do this ugly hack to make sure the test doesn't try and use vol
        # upload
        origscratch = getattr(i, "_get_system_scratchdir")
        try:
            setattr(i, "_get_system_scratchdir",
                    lambda: i.scratchdir)
            self._testInstall(g, "rhel6-kvm-stage1", "rhel6-kvm-stage2")
        finally:
            setattr(i, "_get_system_scratchdir", origscratch)
Esempio n. 24
0
 def testFullKVMWinxp(self):
     utils.set_conn(_plainkvm)
     g = utils.build_win_kvm("/dev/default-pool/winxp.img", fake=False)
     self._testInstall(g, "winxp-kvm-stage1",
                       "winxp-kvm-stage3", "winxp-kvm-stage2")
Esempio n. 25
0
 def testBootWindowsKVM(self):
     utils.set_conn(_plainkvm)
     g = utils.build_win_kvm("/dev/default-pool/winxp.img")
     self._compare(g, "winxp-kvm-stage3", False)
Esempio n. 26
0
 def testContinueWindowsKVM(self):
     utils.set_conn(_plainkvm)
     g = utils.build_win_kvm("/dev/default-pool/winxp.img")
     self._compare(g, "winxp-kvm-stage2", True, True)
Esempio n. 27
0
 def testContinueWindowsKVM(self):
     utils.set_conn(_plainkvm)
     g = utils.build_win_kvm("/default-pool/winxp.img")
     self._compare(g, "winxp-kvm-stage2", True, True)
Esempio n. 28
0
 def testFullKVMWinxp(self):
     utils.set_conn(_plainkvm)
     g = utils.build_win_kvm("/default-pool/winxp.img")
     self._testInstall(g, "winxp-kvm-stage1",
                       "winxp-kvm-stage3", "winxp-kvm-stage2")
Esempio n. 29
0
 def testBootWindowsKVM(self):
     utils.set_conn(_plainkvm)
     g = utils.build_win_kvm("/default-pool/winxp.img")
     self._compare(g, "winxp-kvm-stage3", False)