tendrl_gluster_heal_info.py 文件源码

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

项目:node-agent 作者: Tendrl 项目源码 文件源码
def _parse_heal_info_stats(tree):
    bricks_dict = {}
    for brick in tree.findall("healInfo/bricks/brick"):
        brick_name = brick.find("name").text
        brick_host = brick_name.split(":")[0]
        brick_path = brick_name.split(":")[1]

        # If brick host is returned as an IP conver to FQDN
        try:
            from IPy import IP
            from dns import resolver, reversename
            IP(brick_host)
            addr = reversename.from_address(brick_host)
            brick_host = str(resolver.query(addr, "PTR")[0])[:-1]
        except ValueError:
            pass

        no_of_entries = 0
        try:
            no_of_entries = int(brick.find("numberOfEntries").text)
        except ValueError:
            no_of_entries = 0
        bricks_dict["%s:%s" % (brick_host, brick_path)] = no_of_entries
    return bricks_dict
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号