Skip to content

Commit

Permalink
Merge adfa8cc into 1ffcc18
Browse files Browse the repository at this point in the history
  • Loading branch information
hfeixas committed Jan 26, 2021
2 parents 1ffcc18 + adfa8cc commit 4c32497
Showing 1 changed file with 48 additions and 33 deletions.
81 changes: 48 additions & 33 deletions napalm/ios/ios.py
Expand Up @@ -2274,41 +2274,9 @@ def get_environment(self):

return environment

def get_arp_table(self, vrf=""):
"""
Get arp table information.
Return a list of dictionaries having the following set of keys:
* interface (string)
* mac (string)
* ip (string)
* age (float)
For example::
[
{
'interface' : 'MgmtEth0/RSP0/CPU0/0',
'mac' : '5c:5e:ab:da:3c:f0',
'ip' : '172.17.17.1',
'age' : 1454496274.84
},
{
'interface': 'MgmtEth0/RSP0/CPU0/0',
'mac' : '66:0e:94:96:e0:ff',
'ip' : '172.17.17.2',
'age' : 1435641582.49
}
]
"""
if vrf:
command = "show arp vrf {} | exclude Incomplete".format(vrf)
else:
command = "show arp | exclude Incomplete"

def _get_arp_table(self, command):
arp_table = []

output = self._send_command(command)

# Skip the first line which is a header
output = output.split("\n")
output = output[1:]
Expand Down Expand Up @@ -2345,6 +2313,53 @@ def get_arp_table(self, vrf=""):
"age": age,
}
arp_table.append(entry)

return arp_table

def get_arp_table(self, vrf=""):
"""
Get arp table information.
Return a list of dictionaries having the following set of keys:
* interface (string)
* mac (string)
* ip (string)
* age (float)
For example::
[
{
'interface' : 'MgmtEth0/RSP0/CPU0/0',
'mac' : '5c:5e:ab:da:3c:f0',
'ip' : '172.17.17.1',
'age' : 1454496274.84
},
{
'interface': 'MgmtEth0/RSP0/CPU0/0',
'mac' : '66:0e:94:96:e0:ff',
'ip' : '172.17.17.2',
'age' : 1435641582.49
}
]
"""
arp_table = []
if vrf:
command = "show ip arp vrf {} | exclude Incomplete".format(vrf)
arp_entries = self._get_arp_table(command)
if arp_entries:
arp_table.extend(arp_entries)
else:
vrfs = self._get_vrfs()
for entry in vrfs:
command = "show ip arp vrf {} | exclude Incomplete".format(entry)
arp_entries = self._get_arp_table(command)
if arp_entries:
arp_table.extend(arp_entries)
command = "show ip arp | exclude Incomplete"
arp_entries = self._get_arp_table(command)
if arp_entries:
arp_table.extend(arp_entries)

return arp_table

def cli(self, commands):
Expand Down

0 comments on commit 4c32497

Please sign in to comment.