Fixed routerparser, supports incomplete routes now

This commit is contained in:
Sebastian Lohff 2015-06-01 15:03:49 +02:00
parent 76920cf3f1
commit 902bc6be3d
1 changed files with 5 additions and 3 deletions

View File

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