Commit 53bc555d authored by Tomas Hlavacek's avatar Tomas Hlavacek

Cisco show bgp ipv4/6 unicast <IP address> added.

Fix some woes in Cisco regexps.
Fix minor display bugs.
parent 408d5b2b
...@@ -162,6 +162,7 @@ class Session(object): ...@@ -162,6 +162,7 @@ class Session(object):
def getDecoratedResult(self,decorator_helper,resrange=0): def getDecoratedResult(self,decorator_helper,resrange=0):
if(self.getError()): if(self.getError()):
# TODO
return decorator_helper.pre(self.getResult()) return decorator_helper.pre(self.getResult())
else: else:
result = self.getResult() result = self.getResult()
......
...@@ -45,7 +45,7 @@ BGP_PREFIX_TABLE_HEADER='^(\s)\s+(Network)\s+(Next Hop)\s+(Metric)\s+(LocPrf)\s+ ...@@ -45,7 +45,7 @@ BGP_PREFIX_TABLE_HEADER='^(\s)\s+(Network)\s+(Next Hop)\s+(Metric)\s+(LocPrf)\s+
RESCAN_BGP_IPv4_COMMAND='show bgp ipv4 unicast summary' RESCAN_BGP_IPv4_COMMAND='show bgp ipv4 unicast summary'
RESCAN_BGP_IPv6_COMMAND='show bgp ipv6 unicast summary' RESCAN_BGP_IPv6_COMMAND='show bgp ipv6 unicast summary'
IPV4_SUBNET_REGEXP = '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(/[0-9]{1,2}){0,1}]$' IPV4_SUBNET_REGEXP = '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(/[0-9]{1,2}){0,1}$'
IPV4_ADDRESS_REGEXP = '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$' IPV4_ADDRESS_REGEXP = '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$'
IPV6_SUBNET_REGEXP = '^[0-9a-fA-F:]+(/[0-9]{1,2}){0,1}$' IPV6_SUBNET_REGEXP = '^[0-9a-fA-F:]+(/[0-9]{1,2}){0,1}$'
IPV6_ADDRESS_REGEXP = '^[0-9a-fA-F:]+$' IPV6_ADDRESS_REGEXP = '^[0-9a-fA-F:]+$'
...@@ -483,7 +483,8 @@ class CiscoRouter(ulgmodel.RemoteRouter): ...@@ -483,7 +483,8 @@ class CiscoRouter(ulgmodel.RemoteRouter):
_show_bgp_ipv6_uni_neigh_received_routes, _show_bgp_ipv6_uni_neigh_received_routes,
_show_bgp_ipv4_uni_neigh_advertised, _show_bgp_ipv4_uni_neigh_advertised,
_show_bgp_ipv6_uni_neigh_advertised, _show_bgp_ipv6_uni_neigh_advertised,
ulgmodel.TextCommand('show bgp ipv4 unicast %s',[ulgmodel.TextParameter(IPV4_SUBNET_REGEXP,name=defaults.STRING_IPSUBNET)]),
ulgmodel.TextCommand('show bgp ipv6 unicast %s',[ulgmodel.TextParameter(IPV6_SUBNET_REGEXP,name=defaults.STRING_IPSUBNET)]),
ulgmodel.TextCommand('show ip route %s',[ulgmodel.TextParameter(IPV4_ADDRESS_REGEXP,name=defaults.STRING_IPADDRESS)]), ulgmodel.TextCommand('show ip route %s',[ulgmodel.TextParameter(IPV4_ADDRESS_REGEXP,name=defaults.STRING_IPADDRESS)]),
ulgmodel.TextCommand('show ipv6 unicast route %s',[ulgmodel.TextParameter(IPV6_ADDRESS_REGEXP,name=defaults.STRING_IPADDRESS)]), ulgmodel.TextCommand('show ipv6 unicast route %s',[ulgmodel.TextParameter(IPV6_ADDRESS_REGEXP,name=defaults.STRING_IPADDRESS)]),
ulgmodel.TextCommand('show ip arp %s',[ulgmodel.TextParameter('.*',name=defaults.STRING_NONEORINTORIPADDRESS)]), ulgmodel.TextCommand('show ip arp %s',[ulgmodel.TextParameter('.*',name=defaults.STRING_NONEORINTORIPADDRESS)]),
......
...@@ -250,7 +250,14 @@ class TextCommand(object): ...@@ -250,7 +250,14 @@ class TextCommand(object):
pass pass
def decorateResult(self,result,router=None,decorator_helper=None,resrange=None): def decorateResult(self,result,router=None,decorator_helper=None,resrange=None):
return ("<pre>\n%s\n</pre>" % result, len(str.splitlines(result))) if(resrange != None):
s = str.splitlines(result)
r=''
for sl in s[resrange:resrange+defaults.range_step+1]:
r += sl + "\n"
return ("<pre>\n%s\n</pre>" % r, len(s))
else:
return ("<pre>\n%s\n</pre>" % result, len(str.splitlines(result)))
class AnyCommand(TextCommand): class AnyCommand(TextCommand):
def __init__(self): def __init__(self):
......
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