示例#1
0
    def testXenFVBasic(self):
        cmd = build_commandline("xen:///",
                                name="foo",
                                ram=256,
                                vcpus=1,
                                disks=[("/dev/foo1", 0)],
                                fullvirt=True,
                                arch="x86_64",
                                bridge="br0,br1",
                                virt_type="xenfv",
                                profile_data={
                                    "breed": "redhat",
                                    "os_version": "fedora14",
                                    "interfaces": {
                                        "eth0": {
                                            "interface_type": "na",
                                            "mac_address": "11:22:33:44:55:66",
                                        },
                                        "eth1": {
                                            "interface_type": "na",
                                            "mac_address": "11:22:33:33:22:11",
                                        }
                                    }
                                })

        cmd = " ".join(cmd)
        self.assertEqual(
            cmd,
            ("virt-install --connect xen:/// --name foo --ram 256 --vcpus 1 "
             "--vnc --hvm --pxe --arch x86_64 "
             "--os-variant fedora14 --disk path=/dev/foo1 "
             "--network bridge=br0,mac=11:22:33:44:55:66 "
             "--network bridge=br1,mac=11:22:33:33:22:11 "
             "--wait 0 --noautoconsole"))
示例#2
0
    def testXenFVBasic(self):
        cmd = build_commandline("xen:///",
            name="foo",
            ram=256,
            vcpus=1,
            disks=[("/dev/foo1", 0)],
            fullvirt=True,
            arch="x86_64",
            bridge="br0,br1",
            virt_type="xenfv",
            profile_data = {
                "breed" : "redhat",
                "os_version" : "fedora14",
                "interfaces" : {
                    "eth0": {
                        "interface_type": "na",
                        "mac_address": "11:22:33:44:55:66",
                    }, "eth1": {
                        "interface_type": "na",
                        "mac_address": "11:22:33:33:22:11",
                    }
                }
            })

        cmd = " ".join(cmd)
        self.assertEquals(cmd,
            ("virt-install --connect xen:/// --name foo --ram 256 --vcpus 1 "
             "--vnc --hvm --pxe --arch x86_64 "
             "--os-variant fedora14 --disk path=/dev/foo1 "
             "--network bridge=br0,mac=11:22:33:44:55:66 "
             "--network bridge=br1,mac=11:22:33:33:22:11 "
             "--wait 0 --noautoconsole"))
示例#3
0
    def testXenPVBasic(self):
        cmd = build_commandline("xen:///",
                                name="foo",
                                ram=256,
                                uuid="ad6611b9-98e4-82c8-827f-051b6b6680d7",
                                vcpus=1,
                                bridge="br0",
                                disks=[("/tmp/foo1.img", 8), ("/dev/foo1", 0)],
                                virt_type="xenpv",
                                qemu_driver_type="virtio",
                                qemu_net_type="virtio",
                                profile_data={
                                    "kernel_local": "kernel",
                                    "initrd_local": "initrd",
                                },
                                extra="ks=http://example.com/ks.ks")

        cmd = " ".join(cmd)
        self.assertEqual(cmd, (
            "virt-install --connect xen:/// --name foo --ram 256 --vcpus 1 "
            "--uuid ad6611b9-98e4-82c8-827f-051b6b6680d7 --vnc --paravirt "
            "--boot kernel=kernel,initrd=initrd,kernel_args=ks=http://example.com/ks.ks "
            "--disk path=/tmp/foo1.img,size=8 --disk path=/dev/foo1 "
            "--network bridge=br0 "
            "--wait 0 --noautoconsole"))
示例#4
0
    def testKvmURL(self):
        cmd = build_commandline(
            "qemu:///system",
            name="foo",
            ram=256,
            vcpus=1,
            disks=[("/tmp/foo1.img", 8), ("/dev/foo1", 0)],
            fullvirt=None,
            arch="i686",
            bridge="br0",
            virt_type="kvm",
            qemu_driver_type="virtio",
            qemu_net_type="virtio",
            qemu_machine_type="pc-1.0",
            profile_data={
                "breed": "ubuntu",
                "os_version": "natty",
                "install_tree": "http://example.com/some/install/tree",
            },
            extra="ks=http://example.com/ks.ks text kssendmac")

        cmd = " ".join(cmd)
        self.assertEqual(
            cmd,
            ("virt-install --connect qemu:///system --name foo --ram 256 "
             "--vcpus 1 --vnc --virt-type kvm --machine pc-1.0 "
             "--extra-args=ks=http://example.com/ks.ks text kssendmac "
             "--location http://example.com/some/install/tree/ --arch i686 "
             "--os-variant ubuntunatty "
             "--disk path=/tmp/foo1.img,size=8,bus=virtio "
             "--disk path=/dev/foo1,bus=virtio "
             "--network bridge=br0,model=virtio --wait 0 --noautoconsole"))
示例#5
0
    def testKvmURL(self):
        cmd = build_commandline("qemu:///system",
            name="foo",
            ram=256,
            vcpus=1,
            disks=[("/tmp/foo1.img", 8), ("/dev/foo1", 0)],
            fullvirt=None,
            arch="i686",
            bridge="br0",
            virt_type="kvm",
            qemu_driver_type="virtio",
            qemu_net_type="virtio",
            qemu_machine_type="pc-1.0",
            profile_data = {
                "breed" : "ubuntu",
                "os_version" : "natty",
                "install_tree" : "http://example.com/some/install/tree",
            },
            extra="ks=http://example.com/ks.ks text kssendmac")

        cmd = " ".join(cmd)
        self.assertEquals(cmd,
            ("virt-install --connect qemu:///system --name foo --ram 256 "
             "--vcpus 1 --vnc --virt-type kvm --machine pc-1.0 "
             "--extra-args=ks=http://example.com/ks.ks text kssendmac "
             "--location http://example.com/some/install/tree/ --arch i686 "
             "--os-variant ubuntunatty "
             "--disk path=/tmp/foo1.img,size=8,bus=virtio "
             "--disk path=/dev/foo1,bus=virtio "
             "--network bridge=br0,model=virtio --wait 0 --noautoconsole")
        )
示例#6
0
    def testXenPVBasic(self):
        cmd = build_commandline("xen:///",
            name="foo",
            ram=256,
            uuid="ad6611b9-98e4-82c8-827f-051b6b6680d7",
            vcpus=1,
            bridge="br0",
            disks=[("/tmp/foo1.img", 8), ("/dev/foo1", 0)],
            virt_type="xenpv",
            qemu_driver_type="virtio",
            qemu_net_type="virtio",
            profile_data={
                "kernel_local" : "kernel",
                "initrd_local" : "initrd",
            },
            extra="ks=http://example.com/ks.ks")

        cmd = " ".join(cmd)
        self.assertEquals(cmd,
            ("virt-install --connect xen:/// --name foo --ram 256 --vcpus 1 "
             "--uuid ad6611b9-98e4-82c8-827f-051b6b6680d7 --vnc --paravirt "
             "--boot kernel=kernel,initrd=initrd,kernel_args=ks=http://example.com/ks.ks "
             "--disk path=/tmp/foo1.img,size=8 --disk path=/dev/foo1 "
             "--network bridge=br0 "
             "--wait 0 --noautoconsole"))
示例#7
0
def start_install(*args, **kwargs):
    if 'arch' in kwargs.keys():
        kwargs['arch'] = None  # use host arch for kvm acceleration
    # Use kvm acceleration if available
    try:
        import libvirt
    except:
        raise InfoException(
            "package libvirt is required for installing virtual guests")
    conn = libvirt.openReadOnly(None)
    # See http://libvirt.org/formatcaps.html
    capabilities = parseString(conn.getCapabilities())
    for domain in capabilities.getElementsByTagName("domain"):
        attributes = dict(domain.attributes.items())
        if 'type' in attributes.keys() and attributes['type'] == 'kvm':
            kwargs['virt_type'] = 'kvm'
            break

    virtinstall.create_image_file(*args, **kwargs)
    cmd = virtinstall.build_commandline("qemu:///system", *args, **kwargs)
    rc, result, result_stderr = utils.subprocess_get_response(cmd,
                                                              ignore_rc=True,
                                                              get_stderr=True)
    if rc != 0:
        raise InfoException("command failed (%s): %s %s" %
                            (rc, result, result_stderr))
示例#8
0
    def testImage(self):
        cmd = build_commandline("import",
                                name="foo",
                                ram=256,
                                vcpus=1,
                                fullvirt=True,
                                bridge="br0,br2",
                                disks=[],
                                qemu_driver_type="virtio",
                                qemu_net_type="virtio",
                                profile_data={
                                    "file": "/some/install/image.img",
                                    "network_count": 2,
                                })

        cmd = " ".join(cmd)
        self.assertEqual(
            cmd, ("virt-install --name foo --ram 256 --vcpus 1 --vnc --import "
                  "--disk path=/some/install/image.img --network bridge=br0 "
                  "--network bridge=br2 --wait 0 --noautoconsole"))
示例#9
0
    def testQemuCDROM(self):
        cmd = build_commandline("qemu:///system",
                                name="foo",
                                ram=256,
                                vcpus=1,
                                disks=[("/tmp/foo1.img", 8), ("/dev/foo1", 0)],
                                fullvirt=True,
                                bridge="br0",
                                profile_data={
                                    "breed": "windows",
                                    "file": "/some/cdrom/path.iso",
                                })

        cmd = " ".join(cmd)
        self.assertEquals(
            cmd, ("virt-install --connect qemu:///system --name foo --ram 256 "
                  "--vcpus 1 --vnc --hvm --cdrom /some/cdrom/path.iso "
                  "--os-type windows --disk path=/tmp/foo1.img,size=8 "
                  "--disk path=/dev/foo1 --network bridge=br0 "
                  "--wait 0 --noautoconsole"))
示例#10
0
    def testImage(self):
        cmd = build_commandline("import",
            name="foo",
            ram=256,
            vcpus=1,
            fullvirt=True,
            bridge="br0,br2",
            disks=[],
            qemu_driver_type="virtio",
            qemu_net_type="virtio",
            profile_data = {
                "file" : "/some/install/image.img",
                "network_count" : 2,
            })

        cmd = " ".join(cmd)
        self.assertEquals(cmd,
            ("virt-install --name foo --ram 256 --vcpus 1 --vnc --import "
             "--disk path=/some/install/image.img --network bridge=br0 "
             "--network bridge=br2 --wait 0 --noautoconsole")
        )
示例#11
0
    def testQemuCDROM(self):
        cmd = build_commandline("qemu:///system",
            name="foo",
            ram=256,
            vcpus=1,
            disks=[("/tmp/foo1.img", 8), ("/dev/foo1", 0)],
            fullvirt=True,
            bridge="br0",
            profile_data = {
                "breed" : "windows",
                "file" : "/some/cdrom/path.iso",
            })

        cmd = " ".join(cmd)
        self.assertEquals(cmd,
            ("virt-install --connect qemu:///system --name foo --ram 256 "
             "--vcpus 1 --vnc --hvm --cdrom /some/cdrom/path.iso "
             "--os-type windows --disk path=/tmp/foo1.img,size=8 "
             "--disk path=/dev/foo1 --network bridge=br0 "
             "--wait 0 --noautoconsole")
        )
示例#12
0
def start_install(*args, **kwargs):
    cmd = virtinstall.build_commandline("import", *args, **kwargs)
    subprocess_call(cmd)