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:
@@ -16,7 +16,7 @@ def parse_juniper(output):
|
|||||||
for i, response in enumerate(output):
|
for i, response in enumerate(output):
|
||||||
try:
|
try:
|
||||||
parsed = xmltodict.parse(
|
parsed = xmltodict.parse(
|
||||||
response, force_list=("rt", "rt-entry", "community")
|
response, force_list=("rt", "rt-entry", "community", "nh")
|
||||||
)
|
)
|
||||||
|
|
||||||
if "rpc-reply" in parsed.keys():
|
if "rpc-reply" in parsed.keys():
|
||||||
|
@@ -49,7 +49,16 @@ class JuniperRouteTableEntry(_JuniperBase):
|
|||||||
@root_validator(pre=True)
|
@root_validator(pre=True)
|
||||||
def validate_optional_flags(cls, values):
|
def validate_optional_flags(cls, values):
|
||||||
"""Flatten & rename keys prior to validation."""
|
"""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 = values.get("bgp-path-attributes", {})
|
||||||
_path_attr_agg = _path_attr.get("attr-aggregator", {}).get("attr-value", {})
|
_path_attr_agg = _path_attr.get("attr-aggregator", {}).get("attr-value", {})
|
||||||
values["as-path"] = _path_attr.get("attr-as-path-effective", {}).get(
|
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-as"] = _path_attr_agg.get("aggr-as-number", 0)
|
||||||
values["source-rid"] = _path_attr_agg.get("aggr-router-id", "")
|
values["source-rid"] = _path_attr_agg.get("aggr-router-id", "")
|
||||||
values["peer-rid"] = values["peer-id"]
|
values["peer-rid"] = values["peer-id"]
|
||||||
|
|
||||||
return values
|
return values
|
||||||
|
|
||||||
@validator("validation_state", pre=True, always=True)
|
@validator("validation_state", pre=True, always=True)
|
||||||
|
Reference in New Issue
Block a user