本文整理汇总了Python中tests.utils.diff_compare函数的典型用法代码示例。如果您正苦于以下问题:Python diff_compare函数的具体用法?Python diff_compare怎么用?Python diff_compare使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了diff_compare函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _testNode2DeviceCompare
def _testNode2DeviceCompare(self, nodename, devfile, nodedev=None, is_dup=False):
devfile = os.path.join("tests/nodedev-xml/devxml", devfile)
if not nodedev:
nodedev = self._nodeDevFromName(nodename)
dev = VirtualHostDevice.device_from_node(conn, nodedev=nodedev, is_dup=is_dup)
utils.diff_compare(dev.get_xml_config() + "\n", devfile)
开发者ID:aliceinwire,项目名称:virt-manager,代码行数:7,代码来源:nodedev.py
示例2: _clone_compare
def _clone_compare(self, cloneobj, outbase):
"""Helps compare output from passed clone instance with an xml file"""
outfile = os.path.join(clonexml_dir, outbase + "-out.xml")
cloneobj.setup()
utils.diff_compare(cloneobj.clone_xml, outfile)
开发者ID:DanLipsitt,项目名称:virt-manager,代码行数:7,代码来源:clonetest.py
示例3: _image2XMLhelper
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()
开发者ID:aliceinwire,项目名称:virt-manager,代码行数:35,代码来源:image.py
示例4: _convert_helper
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)
开发者ID:BryanQuigley,项目名称:virt-manager,代码行数:26,代码来源:virtconvtest.py
示例5: _image2XMLhelper
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()
开发者ID:giuseppe,项目名称:virt-manager,代码行数:34,代码来源:image.py
示例6: createVol
def createVol(conn, poolobj, volname=None, input_vol=None, clone_vol=None):
volclass = Storage.StorageVolume.get_volume_for_pool(pool_object=poolobj)
if volname is None:
volname = poolobj.name() + "-vol"
alloc = 5 * 1024 * 1024 * 1024
cap = 10 * 1024 * 1024 * 1024
vol_inst = volclass(conn,
name=volname, capacity=cap, allocation=alloc,
pool=poolobj)
perms = {}
perms["mode"] = 0700
perms["owner"] = 10736
perms["group"] = 10736
vol_inst.perms = perms
if input_vol:
vol_inst.input_vol = input_vol
elif clone_vol:
vol_inst = Storage.CloneVolume(conn, volname, clone_vol)
filename = os.path.join(basepath, vol_inst.name + ".xml")
# Make sure permissions are properly set
utils.diff_compare(vol_inst.get_xml_config(), filename)
return vol_inst.install(meter=False)
开发者ID:TelekomCloud,项目名称:virt-manager,代码行数:29,代码来源:storage.py
示例7: run
def run(self, tests):
filename = self.compare_file
err = None
try:
code, output = self._get_output()
if code == self.SKIP:
tests.skipTest(output)
return
if bool(code) == self.check_success:
raise AssertionError(
("Expected command to %s, but failed.\n" %
(self.check_success and "pass" or "fail")) +
("Command was: %s\n" % self.cmdstr) +
("Error code : %d\n" % code) +
("Output was:\n%s" % output))
if filename:
# Generate test files that don't exist yet
if not os.path.exists(filename):
file(filename, "w").write(output)
utils.diff_compare(output, filename)
except AssertionError, e:
err = self.cmdstr + "\n" + str(e)
开发者ID:TelekomCloud,项目名称:virt-manager,代码行数:27,代码来源:clitest.py
示例8: createVol
def createVol(conn, poolobj, volname=None, input_vol=None, clone_vol=None):
if volname is None:
volname = poolobj.name() + "-vol"
# Format here depends on libvirt-1.2.0 and later
if clone_vol and conn.local_libvirt_version() < 1002000:
logging.debug("skip clone compare")
return
alloc = 5 * 1024 * 1024 * 1024
cap = 10 * 1024 * 1024 * 1024
vol_inst = StorageVolume(conn)
vol_inst.pool = poolobj
vol_inst.name = volname
vol_inst.capacity = cap
vol_inst.allocation = alloc
vol_inst.permissions.mode = "0700"
vol_inst.permissions.owner = "10736"
vol_inst.permissions.group = "10736"
if input_vol:
vol_inst.input_vol = input_vol
vol_inst.sync_input_vol()
elif clone_vol:
vol_inst = StorageVolume(conn, parsexml=clone_vol.XMLDesc(0))
vol_inst.input_vol = clone_vol
vol_inst.sync_input_vol()
vol_inst.name = volname
vol_inst.validate()
filename = os.path.join(basepath, vol_inst.name + ".xml")
utils.diff_compare(vol_inst.get_xml_config(), filename)
return vol_inst.install(meter=False)
开发者ID:aurex-linux,项目名称:virt-manager,代码行数:34,代码来源:storage.py
示例9: testCPUUnknownClear
def testCPUUnknownClear(self):
# Make sure .clear() even removes XML elements we don't know about
basename = "clear-cpu-unknown-vals"
infile = "tests/xmlparse-xml/%s-in.xml" % basename
outfile = "tests/xmlparse-xml/%s-out.xml" % basename
guest = virtinst.Guest(conn, parsexml=file(infile).read())
guest.cpu.clear()
utils.diff_compare(guest.get_xml_config(), outfile)
开发者ID:giuseppe,项目名称:virt-manager,代码行数:9,代码来源:xmlparse.py
示例10: poolCompare
def poolCompare(pool_inst):
filename = os.path.join(basepath, pool_inst.name + ".xml")
out_expect = pool_inst.get_xml_config()
if not os.path.exists(filename):
open(filename, "w").write(out_expect)
utils.diff_compare(out_expect, filename)
return pool_inst.install(build=True, meter=None, create=True)
开发者ID:aurex-linux,项目名称:virt-manager,代码行数:9,代码来源:storage.py
示例11: _testNode2DeviceCompare
def _testNode2DeviceCompare(self, nodename, devfile, nodedev=None):
devfile = os.path.join("tests/nodedev-xml/devxml", devfile)
if not nodedev:
nodedev = self._nodeDevFromName(nodename)
dev = DeviceHostdev(self.conn)
dev.set_from_nodedev(nodedev)
dev.set_defaults(Guest(self.conn))
utils.diff_compare(dev.get_xml() + "\n", devfile)
开发者ID:virt-manager,项目名称:virt-manager,代码行数:9,代码来源:nodedev.py
示例12: run
def run(self, tests):
err = None
try:
conn = None
for idx in reversed(range(len(self.argv))):
if self.argv[idx] == "--connect":
conn = utils.openconn(self.argv[idx + 1])
break
if not conn:
raise RuntimeError("couldn't parse URI from command %s" %
self.argv)
skipmsg = self._skip_msg(conn)
if skipmsg is not None:
tests.skipTest(skipmsg)
return
code, output = self._get_output(conn)
if bool(code) == self.check_success:
raise AssertionError(
("Expected command to %s, but it didn't.\n" %
(self.check_success and "pass" or "fail")) +
("Command was: %s\n" % self.cmdstr) +
("Error code : %d\n" % code) +
("Output was:\n%s" % output))
if self.compare_file:
if (self.compare_check and not
conn.check_support(self.compare_check)):
tests.skipTest(
"Skipping compare check due to lack of support")
return
# Generate test files that don't exist yet
filename = self.compare_file
if utils.REGENERATE_OUTPUT or not os.path.exists(filename):
file(filename, "w").write(output)
if "--print-diff" in self.argv and output.count("\n") > 3:
# 1) Strip header
# 2) Simplify context lines to reduce churn when
# libvirt or testdriver changes
newlines = []
for line in output.splitlines()[3:]:
if line.startswith("@@"):
line = "@@"
newlines.append(line)
output = "\n".join(newlines)
utils.diff_compare(output, filename)
except AssertionError, e:
err = self.cmdstr + "\n" + str(e)
开发者ID:tealover,项目名称:virt-manager,代码行数:56,代码来源:clitest.py
示例13: _compare
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)
开发者ID:aenertia,项目名称:virt-manager,代码行数:11,代码来源:xmlconfig.py
示例14: _clone_compare
def _clone_compare(self, cloneobj, outbase, clone_disks_file=None):
"""Helps compare output from passed clone instance with an xml file"""
outfile = os.path.join(clonexml_dir, outbase + "-out.xml")
cloneobj.setup()
utils.diff_compare(cloneobj.clone_xml, outfile)
if clone_disks_file:
xml_clone_disks = ""
for i in cloneobj.get_clone_disks():
xml_clone_disks += i.get_vol_install().get_xml_config()
utils.diff_compare(xml_clone_disks, clone_disks_file)
开发者ID:CyberShadow,项目名称:virt-manager,代码行数:12,代码来源:clonetest.py
示例15: testISCSIPool
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")
开发者ID:giuseppe,项目名称:virt-manager,代码行数:12,代码来源:xmlparse.py
示例16: testInterfaceVLAN
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")
开发者ID:alexander-manley,项目名称:virt-manager,代码行数:12,代码来源:xmlparse.py
示例17: testNetMulti
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")
开发者ID:giuseppe,项目名称:virt-manager,代码行数:52,代码来源:xmlparse.py
示例18: testChangeSnapshot
def testChangeSnapshot(self):
basename = "change-snapshot"
infile = "tests/xmlparse-xml/%s-in.xml" % basename
outfile = "tests/xmlparse-xml/%s-out.xml" % basename
snap = virtinst.DomainSnapshot(conn, parsexml=file(infile).read())
check = self._make_checker(snap)
check("name", "offline-root-child1", "name-foo")
check("state", "shutoff", "somestate")
check("description", "offline desk", "foo\nnewline\n indent")
check("parent", "offline-root", "newparent")
check("creationTime", 1375905916, 1234)
utils.diff_compare(snap.get_xml_config(), outfile)
开发者ID:TelekomCloud,项目名称:virt-manager,代码行数:14,代码来源:xmlparse.py
示例19: testInterfaceBondMii
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")
开发者ID:alexander-manley,项目名称:virt-manager,代码行数:14,代码来源:xmlparse.py
示例20: define_xml
def define_xml(self, obj, compare=True):
xml = obj.get_xml_config()
logging.debug("Defining interface XML:\n%s", xml)
if compare:
filename = os.path.join(datadir, obj.name + ".xml")
utils.diff_compare(xml, filename)
iface = obj.install()
newxml = iface.XMLDesc(0)
logging.debug("Defined XML:\n%s", newxml)
iface.undefine()
开发者ID:aliceinwire,项目名称:virt-manager,代码行数:14,代码来源:interface.py
注:本文中的tests.utils.diff_compare函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论