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
评论列表
文章目录