From 902bc6be3d35b9f476e902e2218865fc82b208af Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Mon, 1 Jun 2015 15:03:49 +0200 Subject: [PATCH] Fixed routerparser, supports incomplete routes now --- bin/routerparsers.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/routerparsers.py b/bin/routerparsers.py index f03b3f9..99ccbc8 100644 --- a/bin/routerparsers.py +++ b/bin/routerparsers.py @@ -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.)(?P.)(?P.)(?P[0-9./]+)?\s+(?P[0-9./]+)[\s0-9i]+$") + routere = re.compile(r"^(?P.)(?P.)(?P.)(?P[0-9./]+)?\s+(?P[0-9./]+)[\s0-9i?]+$") # find output output = [] @@ -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