1
0
Fork 1
mirror of https://github.com/thatmattlove/hyperglass.git synced 2026-04-17 13:28:27 +00:00
This commit is contained in:
Tan Siewert 2025-10-04 21:35:38 +02:00 committed by GitHub
commit 0a76b8a44e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 3 deletions

View file

@ -31,9 +31,9 @@ class FRRNextHop(_FRRBase):
ip: str
afi: str
metric: int
metric: int = 0
accessible: bool
used: bool
used: bool = False
class FRRPeer(_FRRBase):
@ -65,7 +65,15 @@ class FRRPath(_FRRBase):
def validate_path(cls, values):
"""Extract meaningful data from FRR response."""
new = values.copy()
new["aspath"] = values["aspath"]["segments"][0]["list"]
# Local prefixes (i.e. those in the same ASN) usually have
# no AS_PATH.
# Set AS_PATH to AS0 for now as we cannot ensure that the
# ASN for the prefix is the primary ASN.
if values["aspath"]["length"] != 0:
new["aspath"] = values["aspath"]["segments"][0]["list"]
else:
# TODO: Get an ASN that is reasonable (e.g. primary ASN)
new["aspath"] = [0]
community = values.get("community", {"list": []})
new["community"] = community["list"]
new["lastUpdate"] = values["lastUpdate"]["epoch"]

View file

@ -36,6 +36,10 @@ def parse_frr(output: t.Sequence[str]) -> "OutputDataModel":
_log.debug("Pre-parsed data", data=parsed)
# If empty (i.e. no route found), skip
if not parsed:
continue
validated = FRRBGPTable(**parsed)
bgp_table = validated.bgp_table()