當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。