本文整理汇总了Python中tests.utils.set_conn函数的典型用法代码示例。如果您正苦于以下问题:Python set_conn函数的具体用法?Python set_conn怎么用?Python set_conn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_conn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _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()
示例2: _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()
示例3: testF10
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)
示例4: testF11Xen
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)
示例5: testF11Qemu
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)
示例6: testFullKVMRHEL6
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")
示例7: testCpuset
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)
示例8: testInstallWindowsXenNew
def testInstallWindowsXenNew(self):
def make_guest():
g = utils.get_basic_fullyvirt_guest("xen")
g.os_variant = "winxp"
g.add_device(utils.get_filedisk())
g.add_device(utils.get_blkdisk())
g.add_device(utils.get_virtual_network())
g.add_device(VirtualAudio(g.conn))
return g
utils.set_conn(utils.open_plainxen(connver=3000001))
g = make_guest()
self._compare(g, "install-windowsxp-xenold", True)
utils.set_conn(utils.open_plainxen(connver=3100000))
g = make_guest()
self._compare(g, "install-windowsxp-xennew", True)
示例9: testQEMUDriverName
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)
示例10: testF11AC97
def testF11AC97(self):
def build_guest():
i = utils.make_distro_installer()
g = utils.get_basic_fullyvirt_guest("kvm", installer=i)
g.os_type = "linux"
g.os_variant = "fedora11"
g.installer.cdrom = True
g.add_device(utils.get_floppy())
g.add_device(utils.get_filedisk())
g.add_device(utils.get_blkdisk())
g.add_device(utils.get_virtual_network())
g.add_device(VirtualAudio(g.conn))
return g
utils.set_conn(utils.open_plainkvm(connver=11000))
g = build_guest()
self._compare(g, "install-f11-ac97", False)
utils.set_conn(utils.open_plainkvm(libver=5000))
g = build_guest()
self._compare(g, "install-f11-noac97", False)
utils.set_conn(utils.open_plainkvm(connver=10000))
g = build_guest()
self._compare(g, "install-f11-noac97", False)
示例11: testOSDeviceDefaultChange
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)
示例12: testOSDeviceDefaultChange
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)
示例13: testFullKVMRHEL6
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)
示例14: testFullKVMWinxp
def testFullKVMWinxp(self):
utils.set_conn(_plainkvm)
g = utils.build_win_kvm("/dev/default-pool/winxp.img", fake=False)
self._testInstall(g, "winxp-kvm-stage1",
"winxp-kvm-stage3", "winxp-kvm-stage2")
示例15: testBootWindowsKVM
def testBootWindowsKVM(self):
utils.set_conn(_plainkvm)
g = utils.build_win_kvm("/dev/default-pool/winxp.img")
self._compare(g, "winxp-kvm-stage3", False)