Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

Commit

Permalink
Merge pull request #311 from pierky/get_ipv6_neighbors_table
Browse files Browse the repository at this point in the history
What about a get_ipv6_neighbors_table() method?
  • Loading branch information
ktbyers authored Sep 30, 2017
2 parents 7aefac2 + b47f89b commit a5972f4
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
31 changes: 31 additions & 0 deletions napalm_base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,37 @@ def get_firewall_policies(self):
"""
raise NotImplementedError

def get_ipv6_neighbors_table(self):
"""
Get IPv6 neighbors table information.
Return a list of dictionaries having the following set of keys:
* interface (string)
* mac (string)
* ip (string)
* age (float) in seconds
* state (string)
For example::
[
{
'interface' : 'MgmtEth0/RSP0/CPU0/0',
'mac' : '5c:5e:ab:da:3c:f0',
'ip' : '2001:db8:1:1::1',
'age' : 1454496274.84,
'state' : 'REACH'
},
{
'interface': 'MgmtEth0/RSP0/CPU0/0',
'mac' : '66:0e:94:96:e0:ff',
'ip' : '2001:db8:1:1::2',
'age' : 1435641582.49,
'state' : 'STALE'
}
]
"""
raise NotImplementedError

def compliance_report(self, validation_file=None, validation_source=None):
"""
Return a compliance report.
Expand Down
12 changes: 12 additions & 0 deletions napalm_base/test/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,3 +579,15 @@ def test_get_network_instances(self):
self._test_model(models.network_instance_interfaces, network_instance['interfaces'])

self.assertTrue(result)

def test_get_ipv6_neighbors_table(self):
try:
get_ipv6_neighbors_table = self.device.get_ipv6_neighbors_table()
except NotImplementedError:
raise SkipTest()
result = len(get_ipv6_neighbors_table) > 0

for entry in get_ipv6_neighbors_table:
result = result and self._test_model(models.ipv6_neighbor, entry)

self.assertTrue(result)
11 changes: 11 additions & 0 deletions napalm_base/test/getters.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,17 @@ def test_get_arp_table(self, test_case):

return get_arp_table

@wrap_test_cases
def test_get_ipv6_neighbors_table(self, test_case):
"""Test get_ipv6_neighbors_table."""
get_ipv6_neighbors_table = self.device.get_ipv6_neighbors_table()
assert len(get_ipv6_neighbors_table) > 0

for entry in get_ipv6_neighbors_table:
assert helpers.test_model(models.ipv6_neighbor, entry)

return get_ipv6_neighbors_table

@wrap_test_cases
def test_get_ntp_peers(self, test_case):
"""Test get_ntp_peers."""
Expand Down
8 changes: 8 additions & 0 deletions napalm_base/test/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@
'age': float
}

ipv6_neighbor = {
'interface': text_type,
'mac': text_type,
'ip': text_type,
'age': float,
'state': text_type
}

ntp_peer = {
# will populate it in the future wit potential keys
}
Expand Down

0 comments on commit a5972f4

Please sign in to comment.