Ejemplo n.º 1
0
 def testFedoraTreeinfo(self):
     i = utils.make_distro_installer(
                             location="tests/cli-test-xml/fakefedoratree")
     g = utils.get_basic_fullyvirt_guest(installer=i)
     g.type = "kvm"
     v = i.detect_distro(g)
     self.assertEquals(v, "fedora17")
Ejemplo 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()
Ejemplo n.º 3
0
 def testDoubleInstall(self):
     # Make sure that installing twice generates the same XML, to ensure
     # we aren't polluting the device list during the install process
     i = utils.make_live_installer()
     g = utils.get_basic_fullyvirt_guest(installer=i)
     self._compare(g, "install-fullyvirt-livecd", False)
     self._compare(g, "install-fullyvirt-livecd", False)
Ejemplo n.º 4
0
    def testManyNICs(self):
        i = utils.make_pxe_installer()
        g = utils.get_basic_fullyvirt_guest(installer=i)

        net1 = VirtualNetworkInterface(g.conn)
        net1.type = "user"
        net1.macaddr = "22:11:11:11:11:11"

        net2 = utils.get_virtual_network()
        net3 = utils.get_virtual_network()
        net3.model = "e1000"

        net4 = VirtualNetworkInterface(g.conn)
        net4.source = "foobr0"
        net4.macaddr = "22:22:22:22:22:22"
        net4.target_dev = "foo1"

        net5 = VirtualNetworkInterface(g.conn)
        net5.type = "ethernet"
        net5.macaddr = "00:11:00:22:00:33"
        net5.source = "testeth1"

        g.add_device(net1)
        g.add_device(net2)
        g.add_device(net3)
        g.add_device(net4)
        g.add_device(net5)
        self._compare(g, "boot-many-nics", False)
Ejemplo n.º 5
0
    def testUsb2(self):
        i = utils.make_pxe_installer()
        g = utils.get_basic_fullyvirt_guest(installer=i)

        g.add_usb_ich9_controllers()

        self._compare(g, "boot-usb2", False)
Ejemplo n.º 6
0
 def testFedoraTreeinfo(self):
     i = utils.make_distro_installer(
         location="tests/cli-test-xml/fakefedoratree")
     g = utils.get_basic_fullyvirt_guest(installer=i)
     g.type = "kvm"
     v = i.detect_distro(g)
     self.assertEquals(v, "fedora17")
Ejemplo n.º 7
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()
Ejemplo n.º 8
0
    def testManyDisks2(self):
        i = utils.make_pxe_installer()
        g = utils.get_basic_fullyvirt_guest(installer=i)

        g.add_device(utils.get_filedisk())
        g.add_device(utils.get_blkdisk())
        g.add_device(VirtualDisk(conn=g.conn, path="/dev/loop0",
                                   device=VirtualDisk.DEVICE_CDROM,
                                   driverType="raw"))
        g.add_device(VirtualDisk(conn=g.conn, path="/dev/loop0",
                                   device=VirtualDisk.DEVICE_DISK,
                                   driverName="qemu", format="qcow2"))
        g.add_device(VirtualDisk(conn=g.conn, path=None,
                                   device=VirtualDisk.DEVICE_CDROM,
                                   bus="scsi"))
        g.add_device(VirtualDisk(conn=g.conn, path=None,
                                   device=VirtualDisk.DEVICE_FLOPPY))
        g.add_device(VirtualDisk(conn=g.conn, path="/dev/loop0",
                                   device=VirtualDisk.DEVICE_FLOPPY,
                                   driverName="phy", driverCache="none"))
        disk = VirtualDisk(conn=g.conn, path="/dev/loop0",
                           bus="virtio", driverName="qemu",
                           driverType="qcow2", driverCache="none")
        disk.driver_io = "threads"
        g.add_device(disk)

        self._compare(g, "boot-many-disks2", False)
Ejemplo n.º 9
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()
Ejemplo n.º 10
0
 def testDoubleInstall(self):
     # Make sure that installing twice generates the same XML, to ensure
     # we aren't polluting the device list during the install process
     i = utils.make_live_installer()
     g = utils.get_basic_fullyvirt_guest(installer=i)
     self._compare(g, "install-fullyvirt-livecd", False)
     self._compare(g, "install-fullyvirt-livecd", False)
Ejemplo n.º 11
0
    def testManyNICs(self):
        i = utils.make_pxe_installer()
        g = utils.get_basic_fullyvirt_guest(installer=i)

        net1 = VirtualNetworkInterface(g.conn)
        net1.type = "user"
        net1.macaddr = "22:11:11:11:11:11"

        net2 = utils.get_virtual_network()
        net3 = utils.get_virtual_network()
        net3.model = "e1000"

        net4 = VirtualNetworkInterface(g.conn)
        net4.bridge = "foobr0"
        net4.macaddr = "22:22:22:22:22:22"
        net4.target_dev = "foo1"

        net5 = VirtualNetworkInterface(g.conn)
        net5.type = "ethernet"
        net5.macaddr = "00:11:00:22:00:33"
        net5.source_dev = "testeth1"

        g.add_device(net1)
        g.add_device(net2)
        g.add_device(net3)
        g.add_device(net4)
        g.add_device(net5)
        self._compare(g, "boot-many-nics", False)
Ejemplo n.º 12
0
    def testManyDisks2(self):
        i = utils.make_pxe_installer()
        g = utils.get_basic_fullyvirt_guest(installer=i)

        g.add_device(utils.get_filedisk())
        g.add_device(utils.get_blkdisk())

        d = VirtualDisk(g.conn)
        d.path = "/dev/loop0"
        d.device = d.DEVICE_CDROM
        d.driver_type = "raw"
        d.validate()
        g.add_device(d)

        d = VirtualDisk(g.conn)
        d.path = "/dev/loop0"
        d.device = d.DEVICE_DISK
        d.driver_name = "qemu"
        d.validate()
        g.add_device(d)

        d = VirtualDisk(g.conn)
        d.path = None
        d.device = d.DEVICE_CDROM
        d.bus = "scsi"
        d.validate()
        g.add_device(d)

        d = VirtualDisk(g.conn)
        d.path = None
        d.device = d.DEVICE_FLOPPY
        d.iotune_tbs = 1
        d.iotune_tis = 2
        d.validate()
        g.add_device(d)

        d = VirtualDisk(g.conn)
        d.path = "/dev/loop0"
        d.device = d.DEVICE_FLOPPY
        d.driver_name = "phy"
        d.driver_cache = "none"
        d.iotune_rbs = 5555
        d.iotune_ris = 1234
        d.iotune_wbs = 3
        d.iotune_wis = 4
        d.validate()
        g.add_device(d)

        d = VirtualDisk(g.conn)
        d.path = "/dev/loop0"
        d.bus = "virtio"
        d.driver_name = "qemu"
        d.driver_type = "qcow2"
        d.driver_cache = "none"
        d.driver_io = "threads"
        d.validate()
        g.add_device(d)

        self._compare(g, "boot-many-disks2", False)
Ejemplo n.º 13
0
 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
Ejemplo n.º 14
0
    def testUsb2(self):
        i = utils.make_pxe_installer()
        g = utils.get_basic_fullyvirt_guest(installer=i)

        for dev in virtinst.VirtualController.get_usb2_controllers(g.conn):
            g.add_device(dev)

        self._compare(g, "boot-usb2", False)
Ejemplo n.º 15
0
 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
Ejemplo n.º 16
0
    def testUsb2(self):
        i = utils.make_pxe_installer()
        g = utils.get_basic_fullyvirt_guest(installer=i)

        for dev in virtinst.VirtualController.get_usb2_controllers(g.conn):
            g.add_device(dev)

        self._compare(g, "boot-usb2", False)
Ejemplo n.º 17
0
    def testInstallFVImportMulti(self):
        i = utils.make_import_installer()
        g = utils.get_basic_fullyvirt_guest(installer=i)

        g.installer.bootconfig.enable_bootmenu = False
        g.installer.bootconfig.bootorder = ["hd", "fd", "cdrom", "network"]
        g.add_device(utils.get_filedisk())
        self._compare(g, "install-fullyvirt-import-multiboot", False)
Ejemplo n.º 18
0
    def testInstallFVImportMulti(self):
        i = utils.make_import_installer()
        g = utils.get_basic_fullyvirt_guest(installer=i)

        g.os.enable_bootmenu = False
        g.os.bootorder = ["hd", "fd", "cdrom", "network"]
        g.add_device(utils.get_filedisk())
        self._compare(g, "install-fullyvirt-import-multiboot", False)
Ejemplo n.º 19
0
    def testBootFVPXEAlways(self):
        i = utils.make_pxe_installer()
        g = utils.get_basic_fullyvirt_guest(installer=i)
        g.add_device(utils.get_filedisk())

        g.os.bootorder = [g.os.BOOT_DEVICE_NETWORK]
        g.os.enable_bootmenu = True

        self._compare(g, "boot-fullyvirt-pxe-always", False)
Ejemplo n.º 20
0
    def testManyChars(self):
        i = utils.make_pxe_installer()
        g = utils.get_basic_fullyvirt_guest(installer=i)

        dev1 = VirtualCharDevice.get_dev_instance(g.conn,
                                                  VirtualCharDevice.DEV_SERIAL,
                                                  VirtualCharDevice.CHAR_NULL)
        dev2 = VirtualCharDevice.get_dev_instance(g.conn,
                                                  VirtualCharDevice.DEV_PARALLEL,
                                                  VirtualCharDevice.CHAR_UNIX)
        dev2.source_path = "/tmp/foobar"
        dev3 = VirtualCharDevice.get_dev_instance(g.conn,
                                                  VirtualCharDevice.DEV_SERIAL,
                                                  VirtualCharDevice.CHAR_TCP)
        dev3.protocol = "telnet"
        dev3.source_host = "my.source.host"
        dev3.source_port = "1234"
        dev4 = VirtualCharDevice.get_dev_instance(g.conn,
                                                  VirtualCharDevice.DEV_PARALLEL,
                                                  VirtualCharDevice.CHAR_UDP)
        dev4.bind_host = "my.bind.host"
        dev4.bind_port = "1111"
        dev4.source_host = "my.source.host"
        dev4.source_port = "2222"

        dev5 = VirtualCharDevice.get_dev_instance(g.conn,
                                                  VirtualCharDevice.DEV_CHANNEL,
                                                  VirtualCharDevice.CHAR_PTY)
        dev5.target_type = dev5.CHAR_CHANNEL_TARGET_VIRTIO
        dev5.target_name = "foo.bar.frob"

        dev6 = VirtualCharDevice.get_dev_instance(g.conn,
                                                  VirtualCharDevice.DEV_CONSOLE,
                                                  VirtualCharDevice.CHAR_PTY)

        dev7 = VirtualCharDevice.get_dev_instance(g.conn,
                                                  VirtualCharDevice.DEV_CONSOLE,
                                                  VirtualCharDevice.CHAR_PTY)
        dev7.target_type = dev5.CHAR_CONSOLE_TARGET_VIRTIO

        dev8 = VirtualCharDevice.get_dev_instance(g.conn,
                                                  VirtualCharDevice.DEV_CHANNEL,
                                                  VirtualCharDevice.CHAR_PTY)
        dev8.target_type = dev5.CHAR_CHANNEL_TARGET_GUESTFWD
        dev8.target_address = "1.2.3.4"
        dev8.target_port = "4567"

        g.add_device(dev1)
        g.add_device(dev2)
        g.add_device(dev3)
        g.add_device(dev4)
        g.add_device(dev5)
        g.add_device(dev6)
        g.add_device(dev7)
        g.add_device(dev8)
        self._compare(g, "boot-many-chars", False)
Ejemplo n.º 21
0
    def testInstallFVImportKernel(self):
        i = utils.make_import_installer()
        g = utils.get_basic_fullyvirt_guest(installer=i)

        g.add_device(utils.get_filedisk())
        g.installer.bootconfig.kernel = "kernel"
        g.installer.bootconfig.initrd = "initrd"
        g.installer.bootconfig.kernel_args = "my kernel args"

        self._compare(g, "install-fullyvirt-import-kernel", False)
Ejemplo n.º 22
0
    def testInstallFVImportKernel(self):
        i = utils.make_import_installer()
        g = utils.get_basic_fullyvirt_guest(installer=i)

        g.add_device(utils.get_filedisk())
        g.os.kernel = "kernel"
        g.os.initrd = "initrd"
        g.os.kernel_args = "my kernel args"

        self._compare(g, "install-fullyvirt-import-kernel", False)
Ejemplo n.º 23
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)
Ejemplo n.º 24
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)
Ejemplo n.º 25
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)
Ejemplo n.º 26
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)
Ejemplo n.º 27
0
    def testBootFVPXEAlways(self):
        i = utils.make_pxe_installer()
        g = utils.get_basic_fullyvirt_guest(installer=i)
        g.add_device(utils.get_filedisk())

        g.os.bootorder = [
            g.os.BOOT_DEVICE_NETWORK]
        g.os.enable_bootmenu = True

        self._compare(g, "boot-fullyvirt-pxe-always", False)
Ejemplo n.º 28
0
    def testManySounds(self):
        i = utils.make_pxe_installer()
        g = utils.get_basic_fullyvirt_guest(installer=i)

        g.add_device(VirtualAudio("sb16", conn=g.conn))
        g.add_device(VirtualAudio("es1370", conn=g.conn))
        g.add_device(VirtualAudio("pcspk", conn=g.conn))
        g.add_device(VirtualAudio(conn=g.conn))

        self._compare(g, "boot-many-sounds", False)
Ejemplo n.º 29
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)
Ejemplo n.º 30
0
        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
Ejemplo n.º 31
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)
Ejemplo n.º 32
0
        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
Ejemplo n.º 33
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)
Ejemplo n.º 34
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")
Ejemplo n.º 35
0
    def testDefaultDeviceRemoval(self):
        g = utils.get_basic_fullyvirt_guest()
        g.add_device(utils.get_filedisk())

        inp = VirtualInputDevice(g.conn)
        cons = VirtualCharDevice.get_dev_instance(g.conn,
                                VirtualCharDevice.DEV_CONSOLE,
                                VirtualCharDevice.CHAR_PTY)
        g.add_device(inp)
        g.add_device(cons)

        g.remove_device(inp)
        g.remove_device(cons)

        self._compare(g, "boot-default-device-removal", False)
Ejemplo n.º 36
0
    def testManyHostdevs(self):
        i = utils.make_pxe_installer()
        g = utils.get_basic_fullyvirt_guest(installer=i)

        dev1 = VirtualHostDeviceUSB(g.conn)
        dev1.product = "0x1234"
        dev1.vendor = "0x4321"

        dev2 = VirtualHostDevicePCI(g.conn)
        dev2.bus = "0x11"
        dev2.slot = "0x2"
        dev2.function = "0x3"

        g.add_device(dev1)
        g.add_device(dev2)
        self._compare(g, "boot-many-hostdevs", False)
Ejemplo n.º 37
0
    def testManyChars(self):
        i = utils.make_pxe_installer()
        g = utils.get_basic_fullyvirt_guest(installer=i)

        dev = VirtualSerialDevice(g.conn)
        dev.type = "null"
        g.add_device(dev)

        dev = VirtualParallelDevice(g.conn)
        dev.type = "unix"
        dev.source_path = "/tmp/foobar"
        g.add_device(dev)

        dev = VirtualSerialDevice(g.conn)
        dev.type = "tcp"
        dev.protocol = "telnet"
        dev.source_host = "my.source.host"
        dev.source_port = "1234"
        g.add_device(dev)

        dev = VirtualParallelDevice(g.conn)
        dev.type = "udp"
        dev.bind_host = "my.bind.host"
        dev.bind_port = "1111"
        dev.source_host = "my.source.host"
        dev.source_port = "2222"
        g.add_device(dev)

        dev = VirtualChannelDevice(g.conn)
        dev.type = "pty"
        dev.target_type = dev.CHANNEL_TARGET_VIRTIO
        dev.target_name = "foo.bar.frob"
        g.add_device(dev)

        dev = VirtualConsoleDevice(g.conn)
        dev.type = "pty"
        dev.target_type = dev.CONSOLE_TARGET_VIRTIO
        g.add_device(dev)

        dev = VirtualChannelDevice(g.conn)
        dev.type = "pty"
        dev.target_type = dev.CHANNEL_TARGET_GUESTFWD
        dev.target_address = "1.2.3.4"
        dev.target_port = "4567"
        g.add_device(dev)

        self._compare(g, "boot-many-chars", False)
Ejemplo n.º 38
0
    def testManyChars(self):
        i = utils.make_pxe_installer()
        g = utils.get_basic_fullyvirt_guest(installer=i)

        dev = VirtualSerialDevice(g.conn)
        dev.type = "null"
        g.add_device(dev)

        dev = VirtualParallelDevice(g.conn)
        dev.type = "unix"
        dev.source_path = "/dev/default-pool/foobar"
        g.add_device(dev)

        dev = VirtualSerialDevice(g.conn)
        dev.type = "tcp"
        dev.protocol = "telnet"
        dev.source_host = "my.source.host"
        dev.source_port = "1234"
        g.add_device(dev)

        dev = VirtualParallelDevice(g.conn)
        dev.type = "udp"
        dev.bind_host = "my.bind.host"
        dev.bind_port = "1111"
        dev.source_host = "my.source.host"
        dev.source_port = "2222"
        g.add_device(dev)

        dev = VirtualChannelDevice(g.conn)
        dev.type = "pty"
        dev.target_type = dev.CHANNEL_TARGET_VIRTIO
        dev.target_name = "foo.bar.frob"
        g.add_device(dev)

        dev = VirtualConsoleDevice(g.conn)
        dev.type = "pty"
        dev.target_type = dev.CONSOLE_TARGET_VIRTIO
        g.add_device(dev)

        dev = VirtualChannelDevice(g.conn)
        dev.type = "pty"
        dev.target_type = dev.CHANNEL_TARGET_GUESTFWD
        dev.target_address = "1.2.3.4"
        dev.target_port = "4567"
        g.add_device(dev)

        self._compare(g, "boot-many-chars", False)
Ejemplo n.º 39
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)
Ejemplo n.º 40
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)
Ejemplo n.º 41
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)
Ejemplo n.º 42
0
    def testManySounds(self):
        i = utils.make_pxe_installer()
        g = utils.get_basic_fullyvirt_guest(installer=i)

        d = VirtualAudio(g.conn)
        d.model = "sb16"
        g.add_device(d)

        d = VirtualAudio(g.conn)
        d.model = "es1370"
        g.add_device(d)

        d = VirtualAudio(g.conn)
        d.model = "pcspk"
        g.add_device(d)

        d = VirtualAudio(g.conn)
        g.add_device(d)

        self._compare(g, "boot-many-sounds", False)
Ejemplo n.º 43
0
    def testManySounds(self):
        i = utils.make_pxe_installer()
        g = utils.get_basic_fullyvirt_guest(installer=i)

        d = VirtualAudio(g.conn)
        d.model = "sb16"
        g.add_device(d)

        d = VirtualAudio(g.conn)
        d.model = "es1370"
        g.add_device(d)

        d = VirtualAudio(g.conn)
        d.model = "pcspk"
        g.add_device(d)

        d = VirtualAudio(g.conn)
        g.add_device(d)

        self._compare(g, "boot-many-sounds", False)
Ejemplo n.º 44
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)
Ejemplo n.º 45
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)
Ejemplo n.º 46
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)
Ejemplo n.º 47
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)
Ejemplo n.º 48
0
    def testDefaultBridge(self):
        origfunc = None
        util = None
        try:
            i = utils.make_pxe_installer()
            g = utils.get_basic_fullyvirt_guest(installer=i)
            util = getattr(virtinst, "util")
            origfunc = util.default_bridge

            def newbridge(ignore_conn):
                return ["bridge", "br0"]
            util.default_bridge = newbridge

            dev1 = virtinst.VirtualNetworkInterface(conn=g.conn)
            dev1.macaddr = "22:22:33:44:55:66"
            g.add_device(dev1)

            dev2 = virtinst.VirtualNetworkInterface(conn=g.conn,
                                                parsexml=dev1.get_xml_config())
            dev2.source = None
            dev2.source = "foobr0"
            dev2.macaddr = "22:22:33:44:55:67"
            g.add_device(dev2)

            dev3 = virtinst.VirtualNetworkInterface(conn=g.conn,
                                                parsexml=dev1.get_xml_config())
            dev3.source = None
            dev3.macaddr = "22:22:33:44:55:68"
            g.add_device(dev3)

            self._compare(g, "boot-default-bridge", False, do_create=False)
            dev3.type = dev3.TYPE_USER
            self._compare(g, None, False)
        finally:
            if util and origfunc:
                util.default_bridge = origfunc
Ejemplo n.º 49
0
 def testXMLEscaping(self):
     g = utils.get_basic_fullyvirt_guest()
     g.description = "foooo barrrr \n baz && snarf. '' \"\" @@$\n"
     g.add_device(utils.get_filedisk("/tmp/ISO&'&s"))
     self._compare(g, "misc-xml-escaping", True)
Ejemplo n.º 50
0
    def testManyDevices(self):
        i = utils.make_pxe_installer()
        g = utils.get_basic_fullyvirt_guest(installer=i)

        g.description = "foooo barrrr somedesc"
        g.hugepage = True

        # Hostdevs
        dev1 = VirtualHostDeviceUSB(g.conn)
        dev1.product = "0x1234"
        dev1.vendor = "0x4321"
        g.add_device(dev1)

        # Sound devices
        g.add_device(VirtualAudio("sb16", conn=g.conn))
        g.add_device(VirtualAudio("es1370", conn=g.conn))

        # Disk devices
        g.add_device(VirtualDisk(conn=g.conn, path="/dev/loop0",
                                   device=VirtualDisk.DEVICE_FLOPPY))
        g.add_device(VirtualDisk(conn=g.conn, path="/dev/loop0",
                                   bus="scsi"))
        g.add_device(VirtualDisk(conn=g.conn, path="/tmp", device="floppy"))
        d3 = VirtualDisk(conn=g.conn, path="/default-pool/testvol1.img",
                         bus="scsi", driverName="qemu")
        d3.address.type = "spapr-vio"
        g.add_device(d3)

        # Controller devices
        c1 = VirtualController.get_class_for_type(VirtualController.CONTROLLER_TYPE_IDE)(g.conn)
        c1.index = "3"
        c2 = VirtualController.get_class_for_type(VirtualController.CONTROLLER_TYPE_VIRTIOSERIAL)(g.conn)
        c2.ports = "32"
        c2.vectors = "17"
        g.add_device(c1)
        g.add_device(c2)

        # Network devices
        net1 = utils.get_virtual_network()
        net1.model = "e1000"
        net2 = VirtualNetworkInterface(type="user",
                                       macaddr="22:11:11:11:11:11")
        net3 = VirtualNetworkInterface(type=virtinst.VirtualNetworkInterface.TYPE_VIRTUAL,
                                       macaddr="22:22:22:22:22:22", network="default")
        net3.model = "spapr-vlan"
        net3.set_address("spapr-vio")
        g.add_device(net1)
        g.add_device(net2)
        g.add_device(net3)

        # Character devices
        cdev1 = VirtualCharDevice.get_dev_instance(g.conn,
                                                   VirtualCharDevice.DEV_SERIAL,
                                                   VirtualCharDevice.CHAR_NULL)
        cdev2 = VirtualCharDevice.get_dev_instance(g.conn,
                                                   VirtualCharDevice.DEV_PARALLEL,
                                                   VirtualCharDevice.CHAR_UNIX)
        cdev2.source_path = "/tmp/foobar"
        cdev3 = VirtualCharDevice.get_dev_instance(g.conn,
                                                   VirtualCharDevice.DEV_CHANNEL,
                                                   VirtualCharDevice.CHAR_SPICEVMC)
        g.add_device(cdev1)
        g.add_device(cdev2)
        g.add_device(cdev3)

        # Video Devices
        vdev1 = VirtualVideoDevice(g.conn)
        vdev1.model_type = "vmvga"

        vdev2 = VirtualVideoDevice(g.conn)
        vdev2.model_type = "cirrus"
        vdev2.vram = 10 * 1024
        vdev2.heads = 3

        vdev3 = VirtualVideoDevice(g.conn)
        vdev4 = VirtualVideoDevice(g.conn)
        vdev4.model_type = "qxl"

        g.add_device(vdev1)
        g.add_device(vdev2)
        g.add_device(vdev3)
        g.add_device(vdev4)

        # Watchdog Devices
        wdev2 = VirtualWatchdog(g.conn)
        wdev2.model = "ib700"
        wdev2.action = "none"
        g.add_device(wdev2)

        # Memballoon Devices
        mdev1 = VirtualMemballoon(g.conn)
        mdev1.model = "virtio"
        g.add_device(mdev1)

        # Check keymap autoconfig
        gdev1 = virtinst.VirtualGraphics(conn=g.conn, type="vnc")
        self.assertTrue(gdev1.keymap is not None)
        gdev1.keymap = "en-us"

        # Check keymap None
        gdev2 = virtinst.VirtualGraphics(conn=g.conn, type="vnc")
        gdev2.keymap = None

        gdev3 = virtinst.VirtualGraphics(conn=g.conn, type="sdl")
        gdev4 = virtinst.VirtualGraphics(conn=g.conn, type="spice")
        gdev4.passwdValidTo = "foobar"

        gdev5 = virtinst.VirtualGraphics(conn=g.conn, type="sdl")
        gdev5.xauth = "fooxauth"
        gdev5.display = "foodisplay"
        g.add_device(gdev1)
        g.add_device(gdev2)
        g.add_device(gdev3)
        g.add_device(gdev4)
        g.add_device(gdev5)

        g.clock.offset = "localtime"

        g.seclabel.type = g.seclabel.SECLABEL_TYPE_STATIC
        g.seclabel.model = "selinux"
        g.seclabel.label = "foolabel"
        g.seclabel.imagelabel = "imagelabel"

        self._compare(g, "boot-many-devices", False)