Commit 5819431e authored by Tomas Hlavacek's avatar Tomas Hlavacek

Cisco show output parsing finalized.

Parsing of show bgp ipv4/6 uni neigh ... received-routes/advertised
added.
Minor bugfixes in ulgmodel and ulg.
parent cfb580c6
......@@ -56,4 +56,7 @@ STRING_INTERFACE = "Interface"
# URL generator functions
def getASNURL(asn):
return 'https://apps.db.ripe.net/search/query.html?searchtext=AS%s&flags=C&sources=RIPE_NCC&grssources=&inverse=&types=AUT_NUM' % asn
return 'https://apps.db.ripe.net/search/query.html?searchtext=AS%s&flags=C&sources=&grssources=RIPE;AFRINIC;APNIC;ARIN;LACNIC;JPIRR;RADB&inverse=&types=AUT_NUM' % asn
def getIPPrefixURL(prefix):
return 'https://apps.db.ripe.net/search/query.html?searchtext=%s&flags=C&sources=&grssources=RIPE;AFRINIC;APNIC;ARIN;LACNIC;JPIRR;RADB&inverse=&types=INET6NUM;INETNUM' % prefix
......@@ -466,7 +466,7 @@ if __name__=="__main__":
elif(action == 'display'):
handler.display(**params)
elif(action == 'error'):
handler.display(**params)
handler.error(**params)
elif(action == 'debug'):
handler.debug(**params)
else:
......
......@@ -355,6 +355,30 @@ class CiscoCommandShowBgpIPv46Select(ulgmodel.TextCommand):
name=defaults.STRING_IPADDRESS)
ulgmodel.TextCommand.__init__(self,self.COMMAND_TEXT,param_specs=[peer_param],name=name)
def _decorateASPath(self,path,decorator_helper):
result = ''
for asnm in re.compile('[^\s]+').finditer(path):
asn = asnm.group(0)
if(asn.isdigit()):
result = result + ' ' + decorator_helper.ahref(defaults.getASNURL(asn),asn)
else:
if(re.match('^\s*{[0-9,]+}\s*', asn)):
result = result + '{'
isnext = False
for sasnm in re.compile('[0-9]+').finditer(asn):
sasn = sasnm.group(0)
if(sasn.isdigit()):
if(isnext):
result = result + ',' + decorator_helper.ahref(defaults.getASNURL(sasn),sasn)
else:
isnext = True
result = result + decorator_helper.ahref(defaults.getASNURL(sasn),sasn)
result = result + '}'
else:
result = result + ' ' +asn
return result
def _genTable(self,table_lines,decorator_helper,router):
mls = matchCiscoBGPLines(self.table_header,table_lines)
......@@ -363,12 +387,12 @@ class CiscoCommandShowBgpIPv46Select(ulgmodel.TextCommand):
# generate table content
result.append([
(ml[0],),
(ml[1],),
(decorator_helper.ahref(defaults.getIPPrefixURL(ml[1]),ml[1]),),
(ml[2],),
(ml[3],),
(ml[4],),
(ml[5],),
(ml[6],),
(self._decorateASPath(ml[6],decorator_helper),),
])
return result
......@@ -495,7 +519,7 @@ class CiscoRouter(ulgmodel.RemoteRouter):
peers = []
rlr = re.compile(regexp)
if ipv6:
lines = normalizeBGPIPv6SplitLines(str.splitlines(table))
lines = normalizeBGPIPv6SumSplitLines(str.splitlines(table))
else:
lines = str.splitlines(table)
for tl in lines:
......
......@@ -185,7 +185,7 @@ class SelectionParameter(TextParameter):
return False
def normalizeInput(self,input):
log("DEBUG: returning selection parameterd input: "+str(input))
log("DEBUG: returning selection parameter input: "+str(input))
if(self.checkInput(input)):
return input
else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment