Commit 8fa1f03e by Tomas Hlavacek

Cisco: Implement multiprotocol ping and traceroute

Implement support for multiprotocol ping and traceroute with DNS resolution
for IP addresses. IPv6 has priority in this case, just like in Linux resolver.
parent 4b4e08da
......@@ -34,6 +34,7 @@ STRING_EXPECT_SSH_NEWKEY='Are you sure you want to continue connecting'
STRING_EXPECT_PASSWORD='(P|p)assword:'
STRING_EXPECT_SHELL_PROMPT_REGEXP = '\n[a-zA-Z0-9\._-]+(>|#)'
BGP_IPV6_SUM_TABLE_SPLITLINE_REGEXP='^\s*[0-9a-fA-F:]+\s*$'
IPV46_ADDR_REGEXP = '^[0-9a-fA-F:\.]+$'
BGP_IPV6_TABLE_HEADER_REGEXP='^\s*(Neighbor)\s+(V)\s+(AS)\s+(MsgRcvd)\s+(MsgSent)\s+(TblVer)\s+(InQ)\s+(OutQ)\s+(Up/Down)\s+(State/PfxRcd)\s*$'
BGP_IPV6_TABLE_LINE_REGEXP='^\s*([0-9a-fA-F:]+)\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+([a-zA-Z0-9:]+)\s+([a-zA-Z0-9\(\)]+|[a-zA-Z0-9]+\s\(Admin\))\s*$'
......@@ -739,6 +740,8 @@ class CiscoRouter(ulgmodel.RemoteRouter):
ulgmodel.TextCommand('show mac-address-table interface %s',[ulgmodel.TextParameter('.*',name=defaults.STRING_INTERFACE)]),
_graph_show_bgp_ipv4_uni,
_graph_show_bgp_ipv6_uni,
ulgmodel.TextCommand('ping %s',[ulgmodel.IPv64AddressParameter()]),
ulgmodel.TextCommand('traceroute %s',[ulgmodel.IPv64AddressParameter()]),
]
def _getBGPCommands(self):
......@@ -768,6 +771,8 @@ class CiscoRouter(ulgmodel.RemoteRouter):
CiscoShowBgpIPv6Uni(),
_graph_show_bgp_ipv4_uni,
_graph_show_bgp_ipv6_uni,
ulgmodel.TextCommand('ping %s',[ulgmodel.IPv64AddressParameter()]),
ulgmodel.TextCommand('traceroute %s',[ulgmodel.IPv64AddressParameter()]),
]
......
......@@ -232,6 +232,31 @@ class IPv6AddressParameter(AddressParameter):
AddressParameter.__init__(self,IPV6_ADDRESS_REGEXP,name,default)
self.addrfam=socket.AF_INET6
class IPv64AddressParameter(IPv6AddressParameter):
def __init__(self,name=defaults.STRING_IPADDRESS,default=''):
IPv6AddressParameter.__init__(self,name,default)
self.ip6 = IPv6AddressParameter(name,default)
self.ip4 = IPv4AddressParameter(name,default)
def checkInput(self,input):
if(self.ip6.checkInput(input)):
return True
elif(self.ip4.checkInput(input)):
return True
else:
return False
def normalizeInput(self,input):
res1 = self.ip6.normalizeInput(input)
if(res1 != input):
return res1
res2 = self.ip4.normalizeInput(input)
if(res2 != input):
return res2
return input
class SelectionParameter(TextParameter):
def __init__(self,option_tuples=[],name=defaults.STRING_PARAMETER,default=None):
......@@ -397,8 +422,8 @@ class Router(object):
c.rescanHook(self)
def returnError(self,error=None):
r = '<em>'+defaults.STRING_ERROR_COMMANDRUN
r = r + ': '+error+'</em>' if error else r+'.</em>'
r = defaults.STRING_ERROR_COMMANDRUN
r = r + ': '+error if error else r
return r
def __prepareCommand(self,command,parameters):
......
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