maas_ipmi_autodetect_tool.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:maas 作者: maas 项目源码 文件源码
def detect_ipmi():
    # XXX: andreserl 2013-04-09 bug=1064527: Try to detect if node
    # is a Virtual Machine. If it is, do not try to detect IPMI.
    with open('/proc/cpuinfo', 'r') as cpuinfo:
        for line in cpuinfo:
            if line.startswith('model name') and 'QEMU' in line:
                return (False, None)

    (status, output) = subprocess.getstatusoutput('ipmi-locate')
    show_re = re.compile('(IPMI\ Version:) (\d\.\d)')
    res = show_re.search(output)
    if res is None:
        found = glob.glob("/dev/ipmi[0-9]")
        if len(found):
            return (True, "UNKNOWN: %s" % " ".join(found))
        return (False, "")

    # We've detected IPMI, but it doesn't necessarily mean we can access
    # the BMC. Let's test if we can.
    cmd = 'bmc-config --checkout --key-pair=Lan_Conf:IP_Address_Source'
    (status, output) = subprocess.getstatusoutput(cmd)
    if status != 0:
        return (False, "")

    return (True, res.group(2))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号