当前位置: 首页>>代码示例>>Python>>正文


Python DeviceModel._toint方法代码示例

本文整理汇总了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
开发者ID:madhawa,项目名称:kimchi,代码行数:22,代码来源:vmhostdevs.py

示例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()
开发者ID:aiminickwong,项目名称:kimchi,代码行数:70,代码来源:vmhostdevs.py


注:本文中的wok.plugins.kimchi.model.host.DeviceModel._toint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。