mirror of
https://github.com/thatmattlove/hyperglass.git
synced 2026-04-17 21:38:27 +00:00
Merge 79d235c2ff into fd34bda03f
This commit is contained in:
commit
0a76b8a44e
2 changed files with 15 additions and 3 deletions
|
|
@ -31,9 +31,9 @@ class FRRNextHop(_FRRBase):
|
||||||
|
|
||||||
ip: str
|
ip: str
|
||||||
afi: str
|
afi: str
|
||||||
metric: int
|
metric: int = 0
|
||||||
accessible: bool
|
accessible: bool
|
||||||
used: bool
|
used: bool = False
|
||||||
|
|
||||||
|
|
||||||
class FRRPeer(_FRRBase):
|
class FRRPeer(_FRRBase):
|
||||||
|
|
@ -65,7 +65,15 @@ class FRRPath(_FRRBase):
|
||||||
def validate_path(cls, values):
|
def validate_path(cls, values):
|
||||||
"""Extract meaningful data from FRR response."""
|
"""Extract meaningful data from FRR response."""
|
||||||
new = values.copy()
|
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": []})
|
community = values.get("community", {"list": []})
|
||||||
new["community"] = community["list"]
|
new["community"] = community["list"]
|
||||||
new["lastUpdate"] = values["lastUpdate"]["epoch"]
|
new["lastUpdate"] = values["lastUpdate"]["epoch"]
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,10 @@ def parse_frr(output: t.Sequence[str]) -> "OutputDataModel":
|
||||||
|
|
||||||
_log.debug("Pre-parsed data", data=parsed)
|
_log.debug("Pre-parsed data", data=parsed)
|
||||||
|
|
||||||
|
# If empty (i.e. no route found), skip
|
||||||
|
if not parsed:
|
||||||
|
continue
|
||||||
|
|
||||||
validated = FRRBGPTable(**parsed)
|
validated = FRRBGPTable(**parsed)
|
||||||
bgp_table = validated.bgp_table()
|
bgp_table = validated.bgp_table()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue