Esempio n. 1
0
    def _convert_helper(self, infile, outfile, in_type, disk_format):
        outbuf = StringIO.StringIO()
        def print_cb(msg):
            print >> outbuf, msg

        converter = VirtConverter(conn, infile, print_cb=print_cb)

        if converter.parser.name != in_type:
            raise AssertionError("find_parser_by_file for '%s' returned "
                                 "wrong parser type.\n"
                                 "Expected: %s\n"
                                 "Received: %s\n" %
                                 (infile, in_type, converter.parser.name))

        converter.convert_disks(disk_format, dry=True)
        guest = converter.get_guest()
        ignore, out_xml = guest.start_install(return_xml=True)
        out_expect = out_xml
        if outbuf.getvalue():
            out_expect += ("\n\n" + outbuf.getvalue().replace(base_dir, ""))

        if not conn.check_support(conn.SUPPORT_CONN_VMPORT):
            self.skipTest("Not comparing XML because vmport isn't supported")

        utils.diff_compare(out_expect, outfile)
        utils.test_create(converter.conn, out_xml)
Esempio n. 2
0
 def _clone_define(self, filebase):
     """Take the valid output xml and attempt to define it on the
        connection to ensure we don't get any errors"""
     outfile = os.path.join(clonexml_dir, filebase + "-out.xml")
     outxml = open(outfile).read()
     conn = utils.URIs.open_testdriver_cached()
     utils.test_create(conn, outxml)
Esempio n. 3
0
    def _compare(self, guest, filebase, do_install):
        filename = os.path.join("tests/xmlconfig-xml", filebase + ".xml")

        inst_xml, boot_xml = guest.start_install(return_xml=True, dry=True)
        if do_install:
            actualXML = inst_xml
        else:
            actualXML = boot_xml

        utils.diff_compare(actualXML, filename)
        utils.test_create(guest.conn, actualXML)
Esempio n. 4
0
    def testInterfaceVLAN(self):
        basename = "test-vlan"
        infile = "tests/interface-xml/%s.xml" % basename
        outfile = "tests/xmlparse-xml/interface-%s-out.xml" % basename
        iface = virtinst.Interface(conn, parsexml=file(infile).read())

        check = self._make_checker(iface)
        check("tag", 123, 456)
        check("parent_interface", "eth2", "foonew")

        utils.diff_compare(iface.get_xml_config(), outfile)
        utils.test_create(conn, iface.get_xml_config(), "interfaceDefineXML")
Esempio n. 5
0
    def testISCSIPool(self):
        basename = "pool-iscsi"
        infile = "tests/storage-xml/%s.xml" % basename
        outfile = "tests/xmlparse-xml/%s-out.xml" % basename
        pool = virtinst.StoragePool(conn, parsexml=file(infile).read())

        check = self._make_checker(pool)
        check("host", "some.random.hostname", "my.host")
        check("iqn", "foo.bar.baz.iqn", "my.iqn")

        utils.diff_compare(pool.get_xml_config(), outfile)
        utils.test_create(conn, pool.get_xml_config(), "storagePoolDefineXML")
Esempio n. 6
0
    def testNetMulti(self):
        basename = "network-multi"
        infile = "tests/xmlparse-xml/%s-in.xml" % basename
        outfile = "tests/xmlparse-xml/%s-out.xml" % basename
        net = virtinst.Network(conn, parsexml=file(infile).read())

        check = self._make_checker(net)
        check("name", "ipv6_multirange", "new-foo")
        check("uuid", "41b4afe4-87bb-8087-6724-5e208a2d483a",
                      "41b4afe4-87bb-8087-6724-5e208a2d1111")
        check("bridge", "virbr3", "virbr3new")
        check("stp", True, False)
        check("delay", 0, 2)
        check("domain_name", "net7", "newdom")
        check("ipv6", None, True)
        check("macaddr", None, "52:54:00:69:eb:FF")

        check = self._make_checker(net.forward)
        check("mode", "nat", "route")
        check("dev", None, "eth22")

        self.assertEqual(len(net.ips), 4)
        check = self._make_checker(net.ips[0])
        check("address", "192.168.7.1", "192.168.8.1")
        check("netmask", "255.255.255.0", "255.255.254.0")
        check("tftp", None, "/var/lib/tftproot")
        check("bootp_file", None, "pxeboot.img")
        check("bootp_server", None, "1.2.3.4")

        check = self._make_checker(net.ips[0].ranges[0])
        check("start", "192.168.7.128", "192.168.8.128")
        check("end", "192.168.7.254", "192.168.8.254")

        check = self._make_checker(net.ips[0].hosts[1])
        check("macaddr", "52:54:00:69:eb:91", "52:54:00:69:eb:92")
        check("name", "badbob", "newname")
        check("ip", "192.168.7.3", "192.168.8.3")

        check = self._make_checker(net.ips[1])
        check("family", "ipv6", "ipv6")
        check("prefix", 64, 63)

        r = net.add_route()
        r.family = "ipv4"
        r.address = "192.168.8.0"
        r.prefix = "24"
        r.gateway = "192.168.8.10"
        check = self._make_checker(r)
        check("netmask", None, "foo", None)

        utils.diff_compare(net.get_xml_config(), outfile)
        utils.test_create(conn, net.get_xml_config(), "networkDefineXML")
Esempio n. 7
0
    def testInterfaceBondMii(self):
        basename = "test-bond-mii"
        infile = "tests/interface-xml/%s.xml" % basename
        outfile = "tests/xmlparse-xml/interface-%s-out.xml" % basename
        iface = virtinst.Interface(conn, parsexml=file(infile).read())

        check = self._make_checker(iface)
        check("mii_frequency", 123, 111)
        check("mii_downdelay", 34, 22)
        check("mii_updelay", 12, 33)
        check("mii_carrier_mode", "netif", "ioctl")

        utils.diff_compare(iface.get_xml_config(), outfile)
        utils.test_create(conn, iface.get_xml_config(), "interfaceDefineXML")
Esempio n. 8
0
    def _compare(self, guest, filebase, do_install, do_disk_boot=False,
                 do_create=True):
        filename = filebase and build_xmlfile(filebase) or None

        guest._prepare_install(progress.BaseMeter())
        try:
            actualXML = guest.get_xml_config(install=do_install,
                                             disk_boot=do_disk_boot)

            if filename:
                utils.diff_compare(actualXML, filename)
            if do_create:
                utils.test_create(guest.conn, actualXML)
        finally:
            guest._cleanup_install()
Esempio n. 9
0
    def testGlusterPool(self):
        if not conn.check_support(conn.SUPPORT_CONN_POOL_GLUSTERFS):
            raise unittest.SkipTest("Gluster pools not supported with this "
                "libvirt version.")

        basename = "pool-gluster"
        infile = "tests/storage-xml/%s.xml" % basename
        outfile = "tests/xmlparse-xml/%s-out.xml" % basename
        pool = virtinst.StoragePool(conn, parsexml=file(infile).read())

        check = self._make_checker(pool)
        check("host", "some.random.hostname", "my.host")
        check("source_dir", None, "/foo")

        utils.diff_compare(pool.get_xml_config(), outfile)
        utils.test_create(conn, pool.get_xml_config(), "storagePoolDefineXML")
Esempio n. 10
0
    def testInterfaceBondArp(self):
        basename = "test-bond-arp"
        infile = "tests/interface-xml/%s.xml" % basename
        outfile = "tests/xmlparse-xml/interface-%s-out.xml" % basename
        iface = virtinst.Interface(conn, parsexml=file(infile).read())

        check = self._make_checker(iface)
        check("start_mode", "onboot", "hotplug")
        check("macaddr", "AA:AA:AA:AA:AA:AA", "AA:AA:AA:11:AA:AA")
        check("mtu", 1501, 1234)

        check("bond_mode", None, "active-backup")
        check("arp_interval", 100, 234)
        check("arp_target", "192.168.100.200", "1.2.3.4")
        check("arp_validate_mode", "backup", "active")

        utils.diff_compare(iface.get_xml_config(), outfile)
        utils.test_create(conn, iface.get_xml_config(), "interfaceDefineXML")
Esempio n. 11
0
    def testRBDPool(self):
        basename = "pool-rbd"
        infile = "tests/xmlparse-xml/%s.xml" % basename
        outfile = "tests/xmlparse-xml/%s-out.xml" % basename
        pool = virtinst.StoragePool(conn, parsexml=file(infile).read())

        check = self._make_checker(pool.hosts[0])
        check("name", "ceph-mon-1.example.com")
        check("port", 6789, 1234)
        check = self._make_checker(pool.hosts[1])
        check("name", "ceph-mon-2.example.com", "foo.bar")
        check("port", 6789)
        check = self._make_checker(pool.hosts[2])
        check("name", "ceph-mon-3.example.com")
        check("port", 6789, 1000)
        pool.add_host("frobber", "5555")

        utils.diff_compare(pool.get_xml_config(), outfile)
        utils.test_create(conn, pool.get_xml_config(), "storagePoolDefineXML")
Esempio n. 12
0
    def _compare(self, guest, filebase, do_install, do_disk_boot=False,
                 do_create=True):
        filename = filebase and build_xmlfile(filebase) or None

        cont_xml = None
        inst_xml, boot_xml = guest.start_install(return_xml=True, dry=True)
        if do_disk_boot:
            cont_xml, boot_xml = guest.continue_install(return_xml=True,
                                                        dry=True)

        if do_disk_boot:
            actualXML = cont_xml
        elif do_install:
            actualXML = inst_xml
        else:
            actualXML = boot_xml

        if filename:
            utils.diff_compare(actualXML, filename)
        if do_create:
            utils.test_create(guest.conn, actualXML)
Esempio n. 13
0
    def testFSPool(self):
        basename = "pool-fs"
        infile = "tests/xmlparse-xml/%s.xml" % basename
        outfile = "tests/xmlparse-xml/%s-out.xml" % basename
        pool = virtinst.StoragePool(conn, parsexml=file(infile).read())

        check = self._make_checker(pool)
        check("type", "fs", "dir")
        check("name", "pool-fs", "foo-new")
        check("uuid", "10211510-2115-1021-1510-211510211510",
              "10211510-2115-1021-1510-211510211999")
        check("capacity", 984373075968, 200000)
        check("allocation", 756681687040, 150000)
        check("available", 227691388928, 50000)

        check("format", "auto", "ext3")
        check("source_path", "/some/source/path", "/dev/foo/bar")
        check("target_path", "/some/target/path", "/mnt/my/foo")
        check("source_name", None, "fooname")

        utils.diff_compare(pool.get_xml_config(), outfile)
        utils.test_create(conn, pool.get_xml_config(), "storagePoolDefineXML")
Esempio n. 14
0
    def testFSPool(self):
        basename = "pool-fs"
        infile = "tests/xmlparse-xml/%s.xml" % basename
        outfile = "tests/xmlparse-xml/%s-out.xml" % basename
        pool = virtinst.StoragePool(conn, parsexml=file(infile).read())

        check = self._make_checker(pool)
        check("type", "fs", "dir")
        check("name", "pool-fs", "foo-new")
        check("uuid", "10211510-2115-1021-1510-211510211510",
                      "10211510-2115-1021-1510-211510211999")
        check("capacity", 984373075968, 200000)
        check("allocation", 756681687040, 150000)
        check("available", 227691388928, 50000)

        check("format", "auto", "ext3")
        check("source_path", "/some/source/path", "/dev/foo/bar")
        check("target_path", "/some/target/path", "/mnt/my/foo")
        check("source_name", None, "fooname")

        utils.diff_compare(pool.get_xml_config(), outfile)
        utils.test_create(conn, pool.get_xml_config(), "storagePoolDefineXML")
Esempio n. 15
0
    def testInterfaceBridgeIP(self):
        basename = "test-bridge-ip"
        infile = "tests/interface-xml/%s.xml" % basename
        outfile = "tests/xmlparse-xml/interface-%s-out.xml" % basename
        iface = virtinst.Interface(conn, parsexml=file(infile).read())

        self.assertEquals(len(iface.protocols), 2)
        self.assertEquals(len(iface.interfaces), 3)

        check = self._make_checker(iface)
        check("type", "bridge", "foo", "bridge")
        check("name", "test-bridge-ip", "foo-new")
        check("stp", None, True)
        check("delay", None, 2)

        check = self._make_checker(iface.protocols[0])
        check("family", "ipv4", "foo", "ipv4")
        check("dhcp_peerdns", True, False)
        check("gateway", "1.2.3.4", "5.5.5.5")
        self.assertEquals(iface.protocols[0].ips[1].address, "255.255.255.0")

        check = self._make_checker(iface.protocols[1])
        check("dhcp", True, False)
        check("autoconf", True, False)

        check = self._make_checker(iface.protocols[1].ips[1])
        check("address", "fe80::215:58ff:fe6e:5", "2002::")
        check("prefix", 64, 38)

        # Remove a child interface, verify it's data remains intact
        child_iface = iface.interfaces[1]
        iface.remove_interface(child_iface)

        check = self._make_checker(child_iface)
        check("name", "bond-brbond")
        self.assertEquals(len(child_iface.interfaces), 2)

        utils.diff_compare(iface.get_xml_config(), outfile)
        utils.test_create(conn, iface.get_xml_config(), "interfaceDefineXML")
Esempio n. 16
0
    def testInterfaceBridgeIP(self):
        basename = "test-bridge-ip"
        infile = "tests/interface-xml/%s.xml" % basename
        outfile = "tests/xmlparse-xml/interface-%s-out.xml" % basename
        iface = virtinst.Interface(conn, parsexml=open(infile).read())

        self.assertEqual(len(iface.protocols), 2)
        self.assertEqual(len(iface.interfaces), 3)

        check = self._make_checker(iface)
        check("type", "bridge", "foo", "bridge")
        check("name", "test-bridge-ip", "foo-new")
        check("stp", None, True)
        check("delay", None, 2)

        check = self._make_checker(iface.protocols[0])
        check("family", "ipv4", "foo", "ipv4")
        check("dhcp_peerdns", True, False)
        check("gateway", "1.2.3.4", "5.5.5.5")
        self.assertEqual(iface.protocols[0].ips[1].address, "255.255.255.0")

        check = self._make_checker(iface.protocols[1])
        check("dhcp", True, False)
        check("autoconf", True, False)

        check = self._make_checker(iface.protocols[1].ips[1])
        check("address", "fe80::215:58ff:fe6e:5", "2002::")
        check("prefix", 64, 38)

        # Remove a child interface, verify it's data remains intact
        child_iface = iface.interfaces[1]
        iface.remove_interface(child_iface)

        check = self._make_checker(child_iface)
        check("name", "bond-brbond")
        self.assertEqual(len(child_iface.interfaces), 2)

        utils.diff_compare(iface.get_xml_config(), outfile)
        utils.test_create(conn, iface.get_xml_config(), "interfaceDefineXML")
Esempio n. 17
0
def testRBDPool():
    conn = utils.URIs.open_testdefault_cached()
    basename = "pool-rbd"
    infile = DATADIR + "%s.xml" % basename
    outfile = DATADIR + "%s-out.xml" % basename
    pool = virtinst.StoragePool(conn, parsexml=open(infile).read())

    check = _make_checker(pool.hosts[0])
    check("name", "ceph-mon-1.example.com")
    check("port", 6789, 1234)
    check = _make_checker(pool.hosts[1])
    check("name", "ceph-mon-2.example.com", "foo.bar")
    check("port", 6789)
    check = _make_checker(pool.hosts[2])
    check("name", "ceph-mon-3.example.com")
    check("port", 6789, 1000)
    hostobj = pool.hosts.add_new()
    hostobj.name = "frobber"
    hostobj.port = "5555"

    utils.diff_compare(pool.get_xml(), outfile)
    utils.test_create(conn, pool.get_xml(), "storagePoolDefineXML")
Esempio n. 18
0
    def _convert_helper(self, infile, outfile, in_type, disk_format):
        outbuf = StringIO.StringIO()
        def print_cb(msg):
            print >> outbuf, msg

        converter = VirtConverter(conn, infile, print_cb=print_cb)

        if converter.parser.name != in_type:
            raise AssertionError("find_parser_by_file for '%s' returned "
                                 "wrong parser type.\n"
                                 "Expected: %s\n"
                                 "Received: %s\n" %
                                 (infile, in_type, converter.parser.name))

        converter.convert_disks(disk_format, dry=True)
        guest = converter.get_guest()
        ignore, out_xml = guest.start_install(return_xml=True)
        out_expect = out_xml
        if outbuf.getvalue():
            out_expect += ("\n\n" + outbuf.getvalue())

        utils.diff_compare(out_expect, outfile)
        utils.test_create(converter.conn, out_xml)
Esempio n. 19
0
    def _convert_helper(self, infile, outfile, in_type, disk_format):
        outbuf = StringIO.StringIO()

        def print_cb(msg):
            print >> outbuf, msg

        converter = VirtConverter(conn, infile, print_cb=print_cb)

        if converter.parser.name != in_type:
            raise AssertionError("find_parser_by_file for '%s' returned "
                                 "wrong parser type.\n"
                                 "Expected: %s\n"
                                 "Received: %s\n" %
                                 (infile, in_type, converter.parser.name))

        converter.convert_disks(disk_format, dry=True)
        guest = converter.get_guest()
        ignore, out_xml = guest.start_install(return_xml=True)
        out_expect = out_xml
        if outbuf.getvalue():
            out_expect += ("\n\n" + outbuf.getvalue())

        utils.diff_compare(out_expect, outfile)
        utils.test_create(converter.conn, out_xml)
Esempio n. 20
0
 def _alter_compare(self, actualXML, outfile, support_check=None):
     utils.diff_compare(actualXML, outfile)
     if (support_check and not conn.check_support(support_check)):
         return
     utils.test_create(conn, actualXML)
Esempio n. 21
0
 def _clone_define(self, filebase):
     """Take the valid output xml and attempt to define it on the
        connection to ensure we don't get any errors"""
     outfile = os.path.join(clonexml_dir, filebase + "-out.xml")
     outxml = utils.read_file(outfile)
     utils.test_create(conn, outxml)
Esempio n. 22
0
    def testNetMulti(self):
        basename = "network-multi"
        infile = "tests/xmlparse-xml/%s-in.xml" % basename
        outfile = "tests/xmlparse-xml/%s-out.xml" % basename
        net = virtinst.Network(conn, parsexml=file(infile).read())

        check = self._make_checker(net)
        check("name", "ipv6_multirange", "new-foo")
        check("uuid", "41b4afe4-87bb-8087-6724-5e208a2d483a",
              "41b4afe4-87bb-8087-6724-5e208a2d1111")
        check("bridge", "virbr3", "virbr3new")
        check("stp", True, False)
        check("delay", 0, 2)
        check("domain_name", "net7", "newdom")
        check("ipv6", None, True)
        check("macaddr", None, "52:54:00:69:eb:FF")

        check = self._make_checker(net.forward)
        check("mode", "nat", "route")
        check("dev", None, "eth22")

        check = self._make_checker(net.bandwidth)
        check("inbound_average", "1000", "3000")
        check("inbound_peak", "5000", "4000")
        check("inbound_burst", "5120", "5220")
        check("inbound_floor", None, None)
        check("outbound_average", "1000", "2000")
        check("outbound_peak", "5000", "3000")
        check("outbound_burst", "5120", "5120")

        self.assertEquals(len(net.portgroups), 2)
        check = self._make_checker(net.portgroups[0])
        check("name", "engineering", "foo")
        check("default", True, False)

        self.assertEqual(len(net.ips), 4)
        check = self._make_checker(net.ips[0])
        check("address", "192.168.7.1", "192.168.8.1")
        check("netmask", "255.255.255.0", "255.255.254.0")
        check("tftp", None, "/var/lib/tftproot")
        check("bootp_file", None, "pxeboot.img")
        check("bootp_server", None, "1.2.3.4")

        check = self._make_checker(net.ips[0].ranges[0])
        check("start", "192.168.7.128", "192.168.8.128")
        check("end", "192.168.7.254", "192.168.8.254")

        check = self._make_checker(net.ips[0].hosts[1])
        check("macaddr", "52:54:00:69:eb:91", "52:54:00:69:eb:92")
        check("name", "badbob", "newname")
        check("ip", "192.168.7.3", "192.168.8.3")

        check = self._make_checker(net.ips[1])
        check("family", "ipv6", "ipv6")
        check("prefix", 64, 63)

        r = net.add_route()
        r.family = "ipv4"
        r.address = "192.168.8.0"
        r.prefix = "24"
        r.gateway = "192.168.8.10"
        check = self._make_checker(r)
        check("netmask", None, "foo", None)

        utils.diff_compare(net.get_xml_config(), outfile)
        utils.test_create(conn, net.get_xml_config(), "networkDefineXML")
Esempio n. 23
0
 def _alter_compare(self, actualXML, outfile):
     utils.test_create(conn, actualXML)
     utils.diff_compare(actualXML, outfile)
Esempio n. 24
0
def testNetMulti():
    conn = utils.URIs.open_testdefault_cached()
    basename = "network-multi"
    infile = DATADIR + "%s-in.xml" % basename
    outfile = DATADIR + "%s-out.xml" % basename
    net = virtinst.Network(conn, parsexml=open(infile).read())

    check = _make_checker(net)
    check("name", "ipv6_multirange", "new-foo")
    check("uuid", "41b4afe4-87bb-8087-6724-5e208a2d483a",
          "41b4afe4-87bb-8087-6724-5e208a2d1111")
    check("bridge", "virbr3", "virbr3new")
    check("stp", True, False)
    check("delay", 0, 2)
    check("domain_name", "net7", "newdom")
    check("ipv6", None, True)
    check("macaddr", None, "52:54:00:69:eb:FF")
    check("virtualport_type", None, "openvswitch")

    assert len(net.portgroups) == 2
    check = _make_checker(net.portgroups[0])
    check("name", "engineering", "foo")
    check("default", True, False)

    assert len(net.ips) == 4
    check = _make_checker(net.ips[0])
    check("address", "192.168.7.1", "192.168.8.1")
    check("netmask", "255.255.255.0", "255.255.254.0")
    assert net.can_pxe() is False
    check("tftp", None, "/var/lib/tftproot")
    check("bootp_file", None, "pxeboot.img")
    check("bootp_server", None, "1.2.3.4")
    assert net.can_pxe() is True

    check = _make_checker(net.forward)
    check("mode", "nat", "route")
    check("dev", None, "eth22")
    assert net.can_pxe() is True

    check = _make_checker(net.ips[0].ranges[0])
    check("start", "192.168.7.128", "192.168.8.128")
    check("end", "192.168.7.254", "192.168.8.254")

    check = _make_checker(net.ips[0].hosts[1])
    check("macaddr", "52:54:00:69:eb:91", "52:54:00:69:eb:92")
    check("name", "badbob", "newname")
    check("ip", "192.168.7.3", "192.168.8.3")

    check = _make_checker(net.ips[1])
    check("family", "ipv6", "ipv6")
    check("prefix", 64, 63)

    r = net.routes.add_new()
    r.family = "ipv4"
    r.address = "192.168.8.0"
    r.prefix = "24"
    r.gateway = "192.168.8.10"
    check = _make_checker(r)
    check("netmask", None, "foo", None)

    utils.diff_compare(net.get_xml(), outfile)
    utils.test_create(conn, net.get_xml(), "networkDefineXML")
Esempio n. 25
0
def _alter_compare(conn, actualXML, outfile):
    utils.diff_compare(actualXML, outfile)
    utils.test_create(conn, actualXML)
Esempio n. 26
0
 def _clone_define(self, filebase):
     """Take the valid output xml and attempt to define it on the
        connection to ensure we don't get any errors"""
     outfile = os.path.join(clonexml_dir, filebase + "-out.xml")
     outxml = utils.read_file(outfile)
     utils.test_create(conn, outxml)
Esempio n. 27
0
 def _alter_compare(self, actualXML, outfile, support_check=None):
     utils.diff_compare(actualXML, outfile)
     if (support_check and not conn.check_support(support_check)):
         return
     utils.test_create(conn, actualXML)