openstack判断是否支持numa

openstack 判断是否支持numa


通过对libivrt 版本和qemu版本来判断,目前看代码是只有qemu才支持

MIN_LIBVIRT_HUGEPAGE_VERSION = (1, 2, 8)

MIN_QEMU_NUMA_HUGEPAGE_VERSION = (2, 1, 0)


大概就是qemu版本要大于等于2.1.0,libvirt版本在大于等于 1.2.8 表示支持numa



    def _has_hugepage_support(self):
        # This means that the host can support multiple values for the size
        # field in LibvirtConfigGuestMemoryBackingPage
        supported_archs = [fields.Architecture.I686,
                           fields.Architecture.X86_64,
                           fields.Architecture.AARCH64,
                           fields.Architecture.PPC64LE,
                           fields.Architecture.PPC64]
        caps = self._host.get_capabilities()
        return ((caps.host.cpu.arch in supported_archs) and
                self._host.has_min_version(MIN_LIBVIRT_HUGEPAGE_VERSION,
                                           MIN_QEMU_NUMA_HUGEPAGE_VERSION,
                                           host.HV_DRIVER_QEMU))



    def _version_check(self, lv_ver=None, hv_ver=None, hv_type=None,
                       op=operator.lt):
        """Check libvirt version, hypervisor version, and hypervisor type

        :param hv_type: hypervisor driver from the top of this file.
        """
        conn = self.get_connection()
        try:
            if lv_ver is not None:
                libvirt_version = conn.getLibVersion()
                if op(libvirt_version,
                      versionutils.convert_version_to_int(lv_ver)):
                    return False

            if hv_ver is not None:
                hypervisor_version = conn.getVersion()
                if op(hypervisor_version,
                      versionutils.convert_version_to_int(hv_ver)):
                    return False

            if hv_type is not None:
                hypervisor_type = conn.getType()
                if hypervisor_type != hv_type:
                    return False

            return True
        except Exception:
            return False



其中判断版本号的用到了

import operator

operator.lt


def convert_version_to_int(version):
    """Convert a version to an integer.

    *version* must be a string with dots or a tuple of integers.

    .. versionadded:: 2.0
    """
    try:
        if isinstance(version, six.string_types):
            version = convert_version_to_tuple(version)
        if isinstance(version, tuple):
            return six.moves.reduce(lambda x, y: (x * 1000) + y, version)      这个reduce是为了兼容python3 写的,好麻烦。
    except Exception as ex:
        msg = _("Version %s is invalid.") % version
        six.raise_from(ValueError(msg), ex)


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值