本文整理汇总了Python中virttest.libvirt_xml.devices.librarian.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __type_check__
def __type_check__(self, other):
try:
# Raise error if object isn't dict-like or doesn't have key
device_tag = other['device_tag']
# Check that we have support for this type
librarian.get(device_tag)
except (AttributeError, TypeError, xcepts.LibvirtXMLError):
# Required to always raise TypeError for list API in VMXML class
raise TypeError("Unsupported item type: %s" % str(type(other)))
开发者ID:bingbu,项目名称:virt-test,代码行数:9,代码来源:vm_xml.py
示例2: test_arbitrart_attributes
def test_arbitrart_attributes(self):
parallel = librarian.get('parallel')(virsh_instance = self.dummy_virsh)
serial = librarian.get('serial')(virsh_instance = self.dummy_virsh)
channel = librarian.get('channel')(virsh_instance = self.dummy_virsh)
console = librarian.get('console')(virsh_instance = self.dummy_virsh)
for chardev in (parallel, serial, channel, console):
attribute1 = utils_misc.generate_random_string(10)
value1 = utils_misc.generate_random_string(10)
attribute2 = utils_misc.generate_random_string(10)
value2 = utils_misc.generate_random_string(10)
chardev.add_source(**{attribute1:value1, attribute2:value2})
chardev.add_target(**{attribute1:value1, attribute2:value2})
self.assertEqual(chardev.sources, chardev.targets)
开发者ID:LeiCui,项目名称:virt-test,代码行数:13,代码来源:libvirt_xml_unittest.py
示例3: _from_scratch
def _from_scratch(self):
serial = librarian.get('Serial')(virsh_instance = self.dummy_virsh)
self.assertEqual(serial.device_tag, 'serial')
self.assertEqual(serial.type_name, 'pty')
self.assertEqual(serial.virsh, self.dummy_virsh)
serial.add_source(path='/dev/null')
serial.add_target(port="-1")
return serial
开发者ID:LeiCui,项目名称:virt-test,代码行数:8,代码来源:libvirt_xml_unittest.py
示例4: marshal_to_seclabel
def marshal_to_seclabel(tag, attr_dict, index, libvirtxml):
"""Convert a tag + attributes into a Seclabel instance"""
del index # not used
if tag != 'seclabel':
return None # Don't convert this item
Seclabel = librarian.get('seclabel')
newone = Seclabel(virsh_instance=libvirtxml.virsh)
newone.update(attr_dict)
return newone
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:9,代码来源:disk.py
示例5: test_from_element
def test_from_element(self):
element = xml_utils.ElementTree.fromstring(self.XML)
serial1 = self._from_scratch()
serial2 = librarian.get('Serial').new_from_element(element)
self.assertEqual(serial1, serial2)
# Can't in-place modify the dictionary since it's virtual
serial2.update_target(0, port="0")
self.assertTrue(serial1 != serial2)
serial1.targets = [{'port':'0'}]
self.assertEqual(serial1, serial2)
开发者ID:LeiCui,项目名称:virt-test,代码行数:10,代码来源:libvirt_xml_unittest.py
示例6: test_required
def test_required(self):
address = librarian.get('address')
self.assertRaises(xcepts.LibvirtXMLError,
address.new_from_dict,
{}, self.dummy_virsh)
# no type_name attribute
element = xml_utils.ElementTree.Element('address', {'foo':'bar'})
self.assertRaises(xcepts.LibvirtXMLError,
address.new_from_element,
element, self.dummy_virsh)
element.set('type', 'foobar')
new_address = address.new_from_element(element, self.dummy_virsh)
the_dict = {'type_name':'foobar', 'foo':'bar'}
another_address = address.new_from_dict(the_dict, self.dummy_virsh)
self.assertEqual(str(new_address), str(another_address))
开发者ID:LeiCui,项目名称:virt-test,代码行数:15,代码来源:libvirt_xml_unittest.py
示例7: get_devices
def get_devices(self, device_type=None):
"""
Put all nodes of devices into a VMXMLDevices instance.
"""
devices = VMXMLDevices()
all_devices = self.xmltreefile.find('devices')
if device_type is not None:
device_nodes = all_devices.findall(device_type)
else:
device_nodes = all_devices
for node in device_nodes:
device_tag = node.tag
device_class = librarian.get(device_tag)
new_one = device_class.new_from_element(node)
devices.append(new_one)
return devices
开发者ID:bingbu,项目名称:virt-test,代码行数:16,代码来源:vm_xml.py
示例8: prepare_console_device
def prepare_console_device():
"""
Prepare a serial device XML according to parameters
"""
console = librarian.get('console')(serial_type)
console.target_type = console_target_type
sources = []
logging.debug(sources_str)
for source_str in sources_str.split():
source_dict = {}
for att in source_str.split(','):
key, val = att.split(':')
source_dict[key] = val
sources.append(source_dict)
console.sources = sources
return console
开发者ID:lento-sun,项目名称:tp-libvirt,代码行数:17,代码来源:serial_functional.py
示例9: prepare_serial_device
def prepare_serial_device():
"""
Prepare a serial device XML according to parameters
"""
serial = librarian.get('serial')(serial_type)
serial.target_port = "0"
sources = []
logging.debug(sources_str)
for source_str in sources_str.split():
source_dict = {}
for att in source_str.split(','):
key, val = att.split(':')
source_dict[key] = val
sources.append(source_dict)
serial.sources = sources
return serial
开发者ID:lento-sun,项目名称:tp-libvirt,代码行数:18,代码来源:serial_functional.py
示例10: get_device_class
def get_device_class(type_name):
"""
Return class that handles type_name devices, or raise exception.
"""
return librarian.get(type_name)
开发者ID:bingbu,项目名称:virt-test,代码行数:5,代码来源:vm_xml.py
示例11: test_serial_class
def test_serial_class(self):
Serial = librarian.get('serial')
self.assertTrue(issubclass(Serial, devices_base.UntypedDeviceBase))
self.assertTrue(issubclass(Serial, devices_base.TypedDeviceBase))
开发者ID:LeiCui,项目名称:virt-test,代码行数:4,代码来源:libvirt_xml_unittest.py
示例12: check_xml
def check_xml():
"""
Predict the result serial device and generated console device
and check the result domain XML against expectation
"""
console_cls = librarian.get('console')
local_serial_type = serial_type
if serial_type == 'tls':
local_serial_type = 'tcp'
# Predict expected serial and console XML
expected_console = console_cls(local_serial_type)
if local_serial_type == 'udp':
sources = []
for source in serial_dev.sources:
if 'service' in source and 'mode' not in source:
source['mode'] = 'connect'
sources.append(source)
else:
sources = serial_dev.sources
expected_console.sources = sources
if local_serial_type == 'tcp':
if 'protocol_type' in local_serial_type:
expected_console.protocol_type = serial_dev.protocol_type
else:
expected_console.protocol_type = "raw"
expected_console.target_port = serial_dev.target_port
if 'target_type' in serial_dev:
expected_console.target_type = serial_dev.target_type
expected_console.target_type = console_target_type
logging.debug("Expected console XML is:\n%s", expected_console)
# Get current serial and console XML
current_xml = VMXML.new_from_dumpxml(vm_name)
serial_elem = current_xml.xmltreefile.find('devices/serial')
console_elem = current_xml.xmltreefile.find('devices/console')
if console_elem is None:
test.fail("Expect generate console automatically, "
"but found none.")
if serial_elem and console_target_type != 'serial':
test.fail("Don't Expect exist serial device, "
"but found:\n%s" % serial_elem)
cur_console = console_cls.new_from_element(console_elem)
logging.debug("Current console XML is:\n%s", cur_console)
# Compare current serial and console with oracle.
if not expected_console == cur_console:
# "==" has been override
test.fail("Expect generate console:\n%s\nBut got:\n%s" %
(expected_console, cur_console))
if console_target_type == 'serial':
serial_cls = librarian.get('serial')
expected_serial = serial_cls(local_serial_type)
expected_serial.sources = sources
set_targets(expected_serial)
if local_serial_type == 'tcp':
if 'protocol_type' in local_serial_type:
expected_serial.protocol_type = serial_dev.protocol_type
else:
expected_serial.protocol_type = "raw"
expected_serial.target_port = serial_dev.target_port
if serial_elem is None:
test.fail("Expect exist serial device, "
"but found none.")
cur_serial = serial_cls.new_from_element(serial_elem)
if target_type == 'pci-serial':
if cur_serial.address is None:
test.fail("Expect serial device address is not assigned")
else:
logging.debug("Serial address is: %s", cur_serial.address)
logging.debug("Expected serial XML is:\n%s", expected_serial)
logging.debug("Current serial XML is:\n%s", cur_serial)
# Compare current serial and console with oracle.
if target_type != 'pci-serial' and not expected_serial == cur_serial:
# "==" has been override
test.fail("Expect serial device:\n%s\nBut got:\n "
"%s" % (expected_serial, cur_serial))
开发者ID:balamuruhans,项目名称:tp-libvirt,代码行数:86,代码来源:serial_functional.py
注:本文中的virttest.libvirt_xml.devices.librarian.get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论