2025-02-12 17:36:12 +01:00
|
|
|
#!/bin/env python3
|
|
|
|
from json import loads
|
|
|
|
|
|
|
|
def parse_ip(raw_ip):
|
|
|
|
result = []
|
|
|
|
ip = loads(raw_ip)
|
|
|
|
for interface in ip:
|
|
|
|
if not interface["ifname"].startswith("br-")\
|
|
|
|
and not interface["ifname"].startswith("vet") \
|
|
|
|
and not interface["ifname"].startswith("dock") \
|
|
|
|
and interface["operstate"] != "DOWN" \
|
|
|
|
:
|
|
|
|
result.append(interface)
|
|
|
|
return result
|
|
|
|
|
|
|
|
def parse_debian(content):
|
|
|
|
current_section = ""
|
|
|
|
result = {}
|
|
|
|
for line in content.splitlines():
|
|
|
|
if line.startswith("#####") and line.endswith("#####"):
|
|
|
|
current_section = line.replace(" ","").replace("#","").lower()
|
|
|
|
result[current_section] = ""
|
|
|
|
else:
|
|
|
|
if current_section:
|
2025-02-14 21:11:21 +01:00
|
|
|
result[current_section] += line + "\n"
|
|
|
|
result["ip"] = parse_ip(result["ip"])
|
|
|
|
return result
|
2025-02-12 17:36:12 +01:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|
|
|
|
|