parent
8ce916bd11
commit
933f7d8d00
2 changed files with 9 additions and 9 deletions
|
@ -13,13 +13,6 @@ def parse_ip(raw_ip):
|
||||||
result.append(interface)
|
result.append(interface)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def parse_os(raw_os):
|
|
||||||
result = {}
|
|
||||||
for line in raw_os.splitlines():
|
|
||||||
opt, value = line.split("=")
|
|
||||||
result[opt.lower()] = value
|
|
||||||
return result
|
|
||||||
|
|
||||||
def parse_debian(content):
|
def parse_debian(content):
|
||||||
current_section = ""
|
current_section = ""
|
||||||
result = {}
|
result = {}
|
||||||
|
@ -30,9 +23,11 @@ def parse_debian(content):
|
||||||
else:
|
else:
|
||||||
if current_section:
|
if current_section:
|
||||||
result[current_section] += line + "\n"
|
result[current_section] += line + "\n"
|
||||||
|
for section in result:
|
||||||
|
if section in ["services","routes"]:
|
||||||
|
result[section] = loads(result[section])
|
||||||
result["ip"] = parse_ip(result["ip"])
|
result["ip"] = parse_ip(result["ip"])
|
||||||
result["services"] = loads(result["services"])
|
result["os"] = result["version"]
|
||||||
result["os"] = parse_os(result["version"])
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -12,6 +12,11 @@ interface adresses
|
||||||
{{ "{:<10}".format(interface["ifname"]) }} {% for ip in interface["addr_info"] %} {{ ip["local"] }}/{{ ip["prefixlen"]}}{% endfor %}
|
{{ "{:<10}".format(interface["ifname"]) }} {% for ip in interface["addr_info"] %} {{ ip["local"] }}/{{ ip["prefixlen"]}}{% endfor %}
|
||||||
{% endfor %}========= ==============
|
{% endfor %}========= ==============
|
||||||
|
|
||||||
|
routes
|
||||||
|
######
|
||||||
|
|
||||||
|
{{ routes }}
|
||||||
|
|
||||||
services
|
services
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue