ospf-status: Return {} if no status can be retreived (ospfd is disabled)

This helps yanger to generate a valid configuration.
This commit is contained in:
Mattias Walström
2024-05-24 11:58:47 +02:00
committed by Tobias Waldekranz
parent dfe0a507fc
commit 2096d93282
+6 -3
View File
@@ -13,9 +13,12 @@ def main():
iface_out=subprocess.check_output("vtysh -c 'show ip ospf interface json'", shell=True)
ospf_out=subprocess.check_output("vtysh -c 'show ip ospf json'", shell=True)
neighbor_out=subprocess.check_output("vtysh -c 'show ip ospf neighbor detail json'", shell=True)
interfaces=json.loads(iface_out)
ospf=json.loads(ospf_out)
neighbors=json.loads(neighbor_out)
try:
interfaces=json.loads(iface_out)
ospf=json.loads(ospf_out)
neighbors=json.loads(neighbor_out)
except json.JSONDecodeError:
return {} # OSPFD is most likely not running
for ifname,iface in interfaces["interfaces"].items():
iface["name"] = ifname