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

Added a new method for ISIS adjacency #307

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions napalm_base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1547,3 +1547,94 @@ def compliance_report(self, validation_file='validate.yml'):
report file. See https://napalm.readthedocs.io/en/latest/validate/index.html.
"""
return validate.compliance_report(self, validation_file=validation_file)

def get_isis_adjacencies(self):
"""
Returns a dictionary with ISIS instances.
The keys of the main dictionary represent the name of the ISIS instance.
Each ISIS instance consists of the ISIS adjacencies.

* system-id (string)

The adjacency dictionary contains the following ISIS attributes as keys:

* interface_name (string)
* circuit_type (string)
* network_type (string)
* neighbor_state (string)
* ietf_nsf_flag (bool)
* neighbor_area (string)
* neighbor_uptime (string)
* topologies_supported (list)

Example::
{
"1":
{
"xrv1":
{
"neighbor_area": "49.01fff",
"ietf_nsf_flag": true,
"neighbor_uptime": "5719776",
"circuit_type": "ISIS_LEVELS_2",
"interface_name": "GigabitEthernet0/0/0/4",
"topologies_supported": [
"IPv4 Unicast"
],
"network_type": "ISIS_MEDIA_CLASS_P2P",
"neighbor_state": "ISIS_ADJ_UP_STATE"
},

"xrv2":
{
"neighbor_area": "49.01fff",
"ietf_nsf_flag": true,
"neighbor_uptime": "1974735",
"circuit_type": "ISIS_LEVELS_2",
"interface_name": "GigabitEthernet0/0/0/2",
"topologies_supported": [
"IPv4 Unicast"
],
"network_type": "ISIS_MEDIA_CLASS_P2P",
"neighbor_state": "ISIS_ADJ_UP_STATE"
}
},

"2":
{
"xrv3":
{
"neighbor_area": "49.01fff",
"ietf_nsf_flag": true,
"neighbor_uptime": "1973383",
"circuit_type": "ISIS_LEVELS_12",
"interface_name": "GigabitEthernet0/0/0/1",
"topologies_supported": [
"IPv4 Unicast",
"IPv6 Unicast"
],
"network_type": "ISIS_MEDIA_CLASS_P2P",
"neighbor_state": "ISIS_ADJ_UP_STATE"
}
}
}
"""
raise NotImplementedError

def get_isis_hostnames(self):
"""
Returns a dictionary with keys as ISIS system-id and values as hostname.

* system-id (string): hostname (string)

Example::

{
"0168.0000.0001": "er12-xrv1",
"0168.0000.0003": "er12-xrv3",
"0168.0000.1000": "pr2-xrv6",
"0168.0000.0004": "pr2-xrv4",
"0168.0000.0006": "pr2-xrv6"
}
"""
raise NotImplementedError
27 changes: 27 additions & 0 deletions napalm_base/test/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,3 +579,30 @@ def test_get_network_instances(self):
self._test_model(models.network_instance_interfaces, network_instance['interfaces'])

self.assertTrue(result)

def test_get_isis_adjacencies(self):
"""Test get_isis_adjacency."""
try:
get_isis_adjacencies = self.device.get_isis_adjacencies()
except NotImplementedError:
raise SkipTest()

result = isinstance(get_isis_adjacencies, dict)
for instance_name, instance in get_isis_adjacencies.items():
result = result and isinstance(instance_name, dict)
for neighbor, isis_adjacency_attributes in instance.items():
result = result and \
self._test_model(models.isis_adjacency_attributes,
isis_adjacency_attributes)

self.assertTrue(result)

def test_get_isis_hostnames(self):
"""Test get_isis_hostnames."""
try:
get_isis_hostnames = self.device.get_isis_hostnames()
except NotImplementedError:
raise SkipTest()

result = isinstance(get_isis_hostnames, dict)
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 @@ -514,3 +514,14 @@ def test_get_firewall_policies(self, test_case):
for policy_term in policy_details:
assert helpers.test_model(models.firewall_policies, policy_term)
return get_firewall_policies

@wrap_test_cases
def test_get_isis_adjacencies(self, test_case):
"""Test get_isis_adjacencies method."""
get_isis_adjacencies = self.device.get_isis_adjacencies()
assert len(get_isis_adjacencies) > 0
for instance_name, instance in get_isis_adjacencies.items():
for neighbor, isis_adjacency_attributes in instance.items():
assert helpers.test_model(models.isis_adjacency_attributes,
isis_adjacency_attributes)
return get_isis_adjacencies
11 changes: 11 additions & 0 deletions napalm_base/test/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,14 @@
'dst_zone': text_type,
'action': text_type
}

isis_adjacency_attributes = {
'interface_name': text_type,
'circuit_type': text_type,
'ietf_nsf_flag': bool,
'network_type': text_type,
'neighbor_state': text_type,
'neighbor_area': text_type,
'neighbor_uptime': text_type,
'topologies_supported': list
}