Browse Source

Fixed routerparser, supports incomplete routes now

master
Sebastian Lohff 7 years ago
parent
commit
902bc6be3d
  1. 8
      bin/routerparsers.py

8
bin/routerparsers.py

@ -292,7 +292,7 @@ def _quaggaFindRoutes(raw): @@ -292,7 +292,7 @@ def _quaggaFindRoutes(raw):
# BGP table version is 0, local router ID is 10.50.0.1
# *> 10.3.14.0/27 10.75.0.22 0 65002 65112 i
cmdre = re.compile(r"^([^\s#]+#) show ip bgp$")
routere = re.compile(r"^(?P<status>.)(?P<status2>.)(?P<origin>.)(?P<network>[0-9./]+)?\s+(?P<nexthop>[0-9./]+)[\s0-9i]+$")
routere = re.compile(r"^(?P<status>.)(?P<status2>.)(?P<origin>.)(?P<network>[0-9./]+)?\s+(?P<nexthop>[0-9./]+)[\s0-9i?]+$")
# find output
output = []
@ -336,7 +336,9 @@ def _quaggaFindRoutes(raw): @@ -336,7 +336,9 @@ def _quaggaFindRoutes(raw):
# "parse" path (everything after 61 chars, but no i)
path = filter(lambda _x: _x not in ('', 'i'), line[61:].split(" "))
route = {"prefix": d["network"], "nexthop": d["nexthop"], "path": path, "iBGP": d["origin"] == "i"}
routes.append(route)
# currently skip incomplete routes
if '?' not in path:
route = {"prefix": d["network"], "nexthop": d["nexthop"], "path": path, "iBGP": d["origin"] == "i"}
routes.append(route)
return routes

Loading…
Cancel
Save