本文整理汇总了Python中wok.plugins.kimchi.model.host.DeviceModel._toint方法的典型用法代码示例。如果您正苦于以下问题:Python DeviceModel._toint方法的具体用法?Python DeviceModel._toint怎么用?Python DeviceModel._toint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wok.plugins.kimchi.model.host.DeviceModel
的用法示例。
在下文中一共展示了DeviceModel._toint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _available_slot
# 需要导入模块: from wok.plugins.kimchi.model.host import DeviceModel [as 别名]
# 或者: from wok.plugins.kimchi.model.host.DeviceModel import _toint [as 别名]
def _available_slot(self, dom):
xmlstr = dom.XMLDesc(0)
root = objectify.fromstring(xmlstr)
slots = []
try:
devices = root.devices
slots = [DeviceModel._toint(dev.attrib['slot'])
for dev in devices.findall('.//address')
if 'slot' in dev.attrib]
except AttributeError:
return 1
slots = sorted(slots)
for free, slot in enumerate(slots, start=1):
if free < slot:
return free
return free+1
示例2: VMHostDevsModel
# 需要导入模块: from wok.plugins.kimchi.model.host import DeviceModel [as 别名]
# 或者: from wok.plugins.kimchi.model.host.DeviceModel import _toint [as 别名]
#.........这里部分代码省略.........
host_dev = E.hostdev(source, driver, multi,
mode='subsystem', type='pci', managed='yes')
else:
host_dev = E.hostdev(source, driver,
mode='subsystem', type='pci', managed='yes')
return etree.tostring(host_dev)
@staticmethod
def _validate_pci_passthrough_env():
# Linux kernel < 3.5 doesn't provide /sys/kernel/iommu_groups
if os.path.isdir('/sys/kernel/iommu_groups'):
if not glob.glob('/sys/kernel/iommu_groups/*'):
raise InvalidOperation("KCHVMHDEV0003E")
# Enable virt_use_sysfs on RHEL6 and older distributions
# In recent Fedora, there is no virt_use_sysfs.
out, err, rc = run_command(['getsebool', 'virt_use_sysfs'],
silent=True)
if rc == 0 and out.rstrip('\n') != "virt_use_sysfs --> on":
out, err, rc = run_command(['setsebool', '-P',
'virt_use_sysfs=on'])
if rc != 0:
wok_log.warning("Unable to turn on sebool virt_use_sysfs")
def _available_slot(self, dom):
xmlstr = dom.XMLDesc(0)
root = objectify.fromstring(xmlstr)
slots = []
try:
devices = root.devices
slots = [self.dev_model._toint(dev.attrib['slot'])
for dev in devices.findall('.//address')
if 'slot' in dev.attrib]
except AttributeError:
return 1
slots = sorted(slots)
free = 0
for free, slot in enumerate(slots, start=1):
if free < slot:
return free
return free + 1
def _attach_pci_device(self, cb, params):
cb('Attaching PCI device')
self._cb = cb
vmid = params['vmid']
dev_info = params['dev_info']
lock = params['lock']
try:
self._passthrough_device_validate(dev_info['name'])
except InvalidParameter as e:
cb(e.message, False)
raise
with lock:
try:
self._validate_pci_passthrough_env()