diff --git a/napalm_base/base.py b/napalm_base/base.py index 1912f005..f9bf1c9e 100644 --- a/napalm_base/base.py +++ b/napalm_base/base.py @@ -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 diff --git a/napalm_base/test/base.py b/napalm_base/test/base.py index 0fc17a67..afd9d45f 100644 --- a/napalm_base/test/base.py +++ b/napalm_base/test/base.py @@ -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) diff --git a/napalm_base/test/getters.py b/napalm_base/test/getters.py index db6ebdb7..4a367206 100644 --- a/napalm_base/test/getters.py +++ b/napalm_base/test/getters.py @@ -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 diff --git a/napalm_base/test/models.py b/napalm_base/test/models.py index 37bd84ff..da54b132 100644 --- a/napalm_base/test/models.py +++ b/napalm_base/test/models.py @@ -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 +}