1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

Fix Junos multiple next hop parsing

This commit is contained in:
checktheroads
2020-07-12 11:32:02 -07:00
parent 46a8987225
commit 69416b4dda
2 changed files with 12 additions and 2 deletions

View File

@@ -49,7 +49,16 @@ class JuniperRouteTableEntry(_JuniperBase):
@root_validator(pre=True)
def validate_optional_flags(cls, values):
"""Flatten & rename keys prior to validation."""
values["next-hop"] = values.pop("nh").get("to", "")
next_hop = values.pop("nh")
selected_next_hop = ""
for hop in next_hop:
if "selected-next-hop" in hop:
selected_next_hop = hop.get("to", "")
break
values["next-hop"] = selected_next_hop
_path_attr = values.get("bgp-path-attributes", {})
_path_attr_agg = _path_attr.get("attr-aggregator", {}).get("attr-value", {})
values["as-path"] = _path_attr.get("attr-as-path-effective", {}).get(
@@ -58,6 +67,7 @@ class JuniperRouteTableEntry(_JuniperBase):
values["source-as"] = _path_attr_agg.get("aggr-as-number", 0)
values["source-rid"] = _path_attr_agg.get("aggr-router-id", "")
values["peer-rid"] = values["peer-id"]
return values
@validator("validation_state", pre=True, always=True)