From 7832d0a68dae656cd71ced3eab7c12f028f87408 Mon Sep 17 00:00:00 2001 From: Lee Calder Date: Wed, 11 Dec 2019 17:52:17 +1100 Subject: [PATCH 01/23] IOS driver get_network_instances fix --- napalm/ios/ios.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/napalm/ios/ios.py b/napalm/ios/ios.py index 7a4da2e76..33f0b7f5f 100644 --- a/napalm/ios/ios.py +++ b/napalm/ios/ios.py @@ -3314,7 +3314,11 @@ def get_network_instances(self, name=""): if "No interfaces" in first_part: interfaces = {} else: - interfaces = {itf: {} for itf in if_regex.group(1).split()} + interfaces = {canonical_interface_name(itf): {} for itf in if_regex.group(1).split()} + + # remove interfaces in the VRF from the default VRF + for item in interfaces: + del instances['default']['interfaces']['interface'][item] instances[vrf_name] = { "name": vrf_name, From 223572a3dd8abca7beb1f963675ffba4ddf36e6f Mon Sep 17 00:00:00 2001 From: Lee Calder Date: Wed, 11 Dec 2019 18:45:28 +1100 Subject: [PATCH 02/23] Fix for SVIs --- napalm/ios/ios.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/napalm/ios/ios.py b/napalm/ios/ios.py index 33f0b7f5f..4c45c843f 100644 --- a/napalm/ios/ios.py +++ b/napalm/ios/ios.py @@ -3314,7 +3314,7 @@ def get_network_instances(self, name=""): if "No interfaces" in first_part: interfaces = {} else: - interfaces = {canonical_interface_name(itf): {} for itf in if_regex.group(1).split()} + interfaces = {canonical_interface_name(itf, {'Vl':'Vlan'}): {} for itf in if_regex.group(1).split()} # remove interfaces in the VRF from the default VRF for item in interfaces: From dc0e1661ea1b64c6f66b4095720b39c411e79e3c Mon Sep 17 00:00:00 2001 From: Lee Calder Date: Mon, 20 Jan 2020 00:57:12 +0000 Subject: [PATCH 03/23] changed formatting and ' to " --- napalm/ios/ios.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/napalm/ios/ios.py b/napalm/ios/ios.py index 4c45c843f..ca6d3afe3 100644 --- a/napalm/ios/ios.py +++ b/napalm/ios/ios.py @@ -3314,11 +3314,14 @@ def get_network_instances(self, name=""): if "No interfaces" in first_part: interfaces = {} else: - interfaces = {canonical_interface_name(itf, {'Vl':'Vlan'}): {} for itf in if_regex.group(1).split()} + interfaces = { + canonical_interface_name(itf, {"Vl": "Vlan"}): {} + for itf in if_regex.group(1).split() + } # remove interfaces in the VRF from the default VRF for item in interfaces: - del instances['default']['interfaces']['interface'][item] + del instances["default"]["interfaces"]["interface"][item] instances[vrf_name] = { "name": vrf_name, From 2dbea00809ea2f6ddbb5bb89bc09addec3370c92 Mon Sep 17 00:00:00 2001 From: Lee Calder Date: Wed, 11 Dec 2019 15:55:03 +1100 Subject: [PATCH 04/23] IOS driver get_network_instances fix --- napalm/ios/ios.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/napalm/ios/ios.py b/napalm/ios/ios.py index 0992eaf43..c82db6dc7 100644 --- a/napalm/ios/ios.py +++ b/napalm/ios/ios.py @@ -3394,7 +3394,11 @@ def get_network_instances(self, name=""): if "No interfaces" in first_part: interfaces = {} else: - interfaces = {itf: {} for itf in if_regex.group(1).split()} + interfaces = {canonical_interface_name(itf): {} for itf in if_regex.group(1).split()} + + # remove interfaces in the VRF from the default VRF + for item in interfaces: + del instances['default']['interfaces']['interface'][item] instances[vrf_name] = { "name": vrf_name, From 24e5dc414b8cdd0c37da84952b07a28cfa23e229 Mon Sep 17 00:00:00 2001 From: Lee Calder Date: Wed, 11 Dec 2019 17:20:55 +1100 Subject: [PATCH 05/23] Allow non-exact route lookup --- napalm/ios/ios.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/napalm/ios/ios.py b/napalm/ios/ios.py index c82db6dc7..26d282f45 100644 --- a/napalm/ios/ios.py +++ b/napalm/ios/ios.py @@ -88,6 +88,7 @@ RE_BGP_REMOTE_AS = re.compile(r"remote AS (" + ASN_REGEX + r")") RE_BGP_AS_PATH = re.compile(r"^[ ]{2}([\d\(]([\d\) ]+)|Local)") +RE_RP_ROUTE = re.compile(r"Routing entry for (" + IP_ADDR_REGEX + r"\/\d+)") RE_RP_FROM = re.compile(r"Known via \"([a-z]+)[ \"]") RE_RP_VIA = re.compile(r"via (\S+)") RE_RP_METRIC = re.compile(r"[ ]+Route metric is (\d+)") @@ -2939,8 +2940,11 @@ def get_route_to(self, destination="", protocol="", longer=False): vrfs.append("default") # global VRF ipnet_dest = IPNetwork(destination) prefix = str(ipnet_dest.network) - netmask = str(ipnet_dest.netmask) - routes = {destination: []} + netmask = "" + routes = {} + if '/' in destination: + netmask = str(ipnet_dest.netmask) + routes = {destination: []} commands = [] for _vrf in vrfs: if _vrf == "default": @@ -2961,6 +2965,14 @@ def get_route_to(self, destination="", protocol="", longer=False): for (outitem, _vrf) in zip(output, vrfs): # for all VRFs route_proto_regex = RE_RP_FROM.search(outitem) if route_proto_regex: + route_match = destination + if netmask == "": + # Get the matching route for a non-exact lookup + route_match_regex = RE_RP_ROUTE.search(outitem) + if route_match_regex: + route_match = route_match_regex.group(1) + if not route_match in routes: + routes[route_match] = [] # routing protocol name (bgp, ospf, ...) route_proto = route_proto_regex.group(1) rdb = outitem.split("Routing Descriptor Blocks:") @@ -3027,9 +3039,9 @@ def get_route_to(self, destination="", protocol="", longer=False): destination, _vrf, nh, ip_version ) nh_line_found = ( - False # for next RT entry processing ... - ) - routes[destination].append(route_entry) + False + ) # for next RT entry processing ... + routes[route_match].append(route_entry) return routes def get_snmp_information(self): From 21bc88625ad371dc6e74c08b7633c9f2f44735a7 Mon Sep 17 00:00:00 2001 From: Lee Calder Date: Wed, 11 Dec 2019 17:39:22 +1100 Subject: [PATCH 06/23] reverted commits --- napalm/ios/ios.py | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/napalm/ios/ios.py b/napalm/ios/ios.py index 26d282f45..802ea329f 100644 --- a/napalm/ios/ios.py +++ b/napalm/ios/ios.py @@ -88,7 +88,6 @@ RE_BGP_REMOTE_AS = re.compile(r"remote AS (" + ASN_REGEX + r")") RE_BGP_AS_PATH = re.compile(r"^[ ]{2}([\d\(]([\d\) ]+)|Local)") -RE_RP_ROUTE = re.compile(r"Routing entry for (" + IP_ADDR_REGEX + r"\/\d+)") RE_RP_FROM = re.compile(r"Known via \"([a-z]+)[ \"]") RE_RP_VIA = re.compile(r"via (\S+)") RE_RP_METRIC = re.compile(r"[ ]+Route metric is (\d+)") @@ -2940,11 +2939,8 @@ def get_route_to(self, destination="", protocol="", longer=False): vrfs.append("default") # global VRF ipnet_dest = IPNetwork(destination) prefix = str(ipnet_dest.network) - netmask = "" - routes = {} - if '/' in destination: - netmask = str(ipnet_dest.netmask) - routes = {destination: []} + netmask = str(ipnet_dest.netmask) + routes = {destination: []} commands = [] for _vrf in vrfs: if _vrf == "default": @@ -2965,14 +2961,6 @@ def get_route_to(self, destination="", protocol="", longer=False): for (outitem, _vrf) in zip(output, vrfs): # for all VRFs route_proto_regex = RE_RP_FROM.search(outitem) if route_proto_regex: - route_match = destination - if netmask == "": - # Get the matching route for a non-exact lookup - route_match_regex = RE_RP_ROUTE.search(outitem) - if route_match_regex: - route_match = route_match_regex.group(1) - if not route_match in routes: - routes[route_match] = [] # routing protocol name (bgp, ospf, ...) route_proto = route_proto_regex.group(1) rdb = outitem.split("Routing Descriptor Blocks:") @@ -3041,7 +3029,7 @@ def get_route_to(self, destination="", protocol="", longer=False): nh_line_found = ( False ) # for next RT entry processing ... - routes[route_match].append(route_entry) + routes[destination].append(route_entry) return routes def get_snmp_information(self): @@ -3406,11 +3394,7 @@ def get_network_instances(self, name=""): if "No interfaces" in first_part: interfaces = {} else: - interfaces = {canonical_interface_name(itf): {} for itf in if_regex.group(1).split()} - - # remove interfaces in the VRF from the default VRF - for item in interfaces: - del instances['default']['interfaces']['interface'][item] + interfaces = {itf: {} for itf in if_regex.group(1).split()} instances[vrf_name] = { "name": vrf_name, From f2a51968cbb6c96939a900d0dccb0cae63caed4a Mon Sep 17 00:00:00 2001 From: Lee Calder Date: Wed, 11 Dec 2019 18:04:08 +1100 Subject: [PATCH 07/23] Allow non-exact route lookup --- napalm/ios/ios.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/napalm/ios/ios.py b/napalm/ios/ios.py index 802ea329f..4002e0df5 100644 --- a/napalm/ios/ios.py +++ b/napalm/ios/ios.py @@ -88,6 +88,7 @@ RE_BGP_REMOTE_AS = re.compile(r"remote AS (" + ASN_REGEX + r")") RE_BGP_AS_PATH = re.compile(r"^[ ]{2}([\d\(]([\d\) ]+)|Local)") +RE_RP_ROUTE = re.compile(r"Routing entry for (" + IP_ADDR_REGEX + r"\/\d+)") RE_RP_FROM = re.compile(r"Known via \"([a-z]+)[ \"]") RE_RP_VIA = re.compile(r"via (\S+)") RE_RP_METRIC = re.compile(r"[ ]+Route metric is (\d+)") @@ -2939,8 +2940,11 @@ def get_route_to(self, destination="", protocol="", longer=False): vrfs.append("default") # global VRF ipnet_dest = IPNetwork(destination) prefix = str(ipnet_dest.network) - netmask = str(ipnet_dest.netmask) - routes = {destination: []} + netmask = "" + routes = {} + if '/' in destination: + netmask = str(ipnet_dest.netmask) + routes = {destination: []} commands = [] for _vrf in vrfs: if _vrf == "default": @@ -2961,6 +2965,14 @@ def get_route_to(self, destination="", protocol="", longer=False): for (outitem, _vrf) in zip(output, vrfs): # for all VRFs route_proto_regex = RE_RP_FROM.search(outitem) if route_proto_regex: + route_match = destination + if netmask == "": + # Get the matching route for a non-exact lookup + route_match_regex = RE_RP_ROUTE.search(outitem) + if route_match_regex: + route_match = route_match_regex.group(1) + if not route_match in routes: + routes[route_match] = [] # routing protocol name (bgp, ospf, ...) route_proto = route_proto_regex.group(1) rdb = outitem.split("Routing Descriptor Blocks:") @@ -3029,7 +3041,7 @@ def get_route_to(self, destination="", protocol="", longer=False): nh_line_found = ( False ) # for next RT entry processing ... - routes[destination].append(route_entry) + routes[route_match].append(route_entry) return routes def get_snmp_information(self): From 46b642ea7a619f3b200df645f65181f72c2937a0 Mon Sep 17 00:00:00 2001 From: chonty Date: Mon, 20 Jan 2020 01:09:02 +0000 Subject: [PATCH 08/23] "if not x in y" changed to "if x not in y" --- napalm/ios/ios.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/napalm/ios/ios.py b/napalm/ios/ios.py index 4002e0df5..4342aa1a0 100644 --- a/napalm/ios/ios.py +++ b/napalm/ios/ios.py @@ -2971,7 +2971,7 @@ def get_route_to(self, destination="", protocol="", longer=False): route_match_regex = RE_RP_ROUTE.search(outitem) if route_match_regex: route_match = route_match_regex.group(1) - if not route_match in routes: + if route_match not in routes: routes[route_match] = [] # routing protocol name (bgp, ospf, ...) route_proto = route_proto_regex.group(1) From 12724445f6d5b2538ca67d3330f23cfca1a27e92 Mon Sep 17 00:00:00 2001 From: chonty Date: Mon, 20 Jan 2020 01:18:37 +0000 Subject: [PATCH 09/23] ' to " --- napalm/ios/ios.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/napalm/ios/ios.py b/napalm/ios/ios.py index 4342aa1a0..25d93e525 100644 --- a/napalm/ios/ios.py +++ b/napalm/ios/ios.py @@ -2942,7 +2942,7 @@ def get_route_to(self, destination="", protocol="", longer=False): prefix = str(ipnet_dest.network) netmask = "" routes = {} - if '/' in destination: + if "/" in destination: netmask = str(ipnet_dest.netmask) routes = {destination: []} commands = [] From a52fa118365fa8db6d5bdb905b85de930e8ec1ec Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 29 Jul 2020 06:45:48 +0000 Subject: [PATCH 10/23] Bump tox from 3.18.0 to 3.18.1 Bumps [tox](https://github.com/tox-dev/tox) from 3.18.0 to 3.18.1. - [Release notes](https://github.com/tox-dev/tox/releases) - [Changelog](https://github.com/tox-dev/tox/blob/master/docs/changelog.rst) - [Commits](https://github.com/tox-dev/tox/compare/3.18.0...3.18.1) Signed-off-by: dependabot-preview[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 99dc168ad..062fc22e3 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -8,4 +8,4 @@ pytest-json==0.4.0 pytest-pythonpath==0.7.3 pylama==7.7.1 mock==4.0.2 -tox==3.18.0 \ No newline at end of file +tox==3.18.1 \ No newline at end of file From ce790e38b7e49454ed6b2de3bcef97ec923de016 Mon Sep 17 00:00:00 2001 From: Kirk Byers Date: Tue, 4 Aug 2020 08:47:50 -0700 Subject: [PATCH 11/23] Allow positional arguments for run_commands (#1263) --- napalm/eos/pyeapi_syntax_wrapper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/napalm/eos/pyeapi_syntax_wrapper.py b/napalm/eos/pyeapi_syntax_wrapper.py index 246b185c9..c240df3d4 100644 --- a/napalm/eos/pyeapi_syntax_wrapper.py +++ b/napalm/eos/pyeapi_syntax_wrapper.py @@ -25,7 +25,7 @@ def update_cli_version(self, version): """ self.cli_version = version - def run_commands(self, commands, **kwargs): + def run_commands(self, commands, *args, **kwargs): """ Run commands wrapper :param commands: list of commands @@ -39,4 +39,4 @@ def run_commands(self, commands, **kwargs): else: commands = [cli_convert(cmd, self.cli_version) for cmd in commands] - return super(Node, self).run_commands(commands, **kwargs) + return super(Node, self).run_commands(commands, *args, **kwargs) From a54ceba4ad9b92240d5f3ddbd4e81c674ae5b1bb Mon Sep 17 00:00:00 2001 From: chonty Date: Wed, 5 Aug 2020 19:50:35 +1000 Subject: [PATCH 12/23] error handling: ret default instance when no VRFs --- napalm/ios/ios.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/napalm/ios/ios.py b/napalm/ios/ios.py index 6d4832c76..344925bff 100644 --- a/napalm/ios/ios.py +++ b/napalm/ios/ios.py @@ -3311,6 +3311,9 @@ def get_network_instances(self, name=""): first_part = vrf.split("Address family")[0] + if not first_part: + return instances + # retrieve the name of the VRF and the Route Distinguisher vrf_name, RD = re.match(r"^VRF (\S+).*RD (.*);", first_part).groups() if RD == "": From 8522d2480deed7840a25f11c55b0ed3bd7370e85 Mon Sep 17 00:00:00 2001 From: chonty Date: Wed, 5 Aug 2020 19:50:46 +1000 Subject: [PATCH 13/23] tests --- .../no_vrf/expected_result.json | 29 +++++ .../no_vrf/show_ip_interface_brief.txt | 17 +++ .../no_vrf/show_vrf_detail.txt | 0 .../normal/expected_result.json | 121 +++++++----------- .../normal/show_ip_interface_brief.txt | 34 ++--- .../normal/show_vrf_detail.txt | 32 ++--- 6 files changed, 120 insertions(+), 113 deletions(-) create mode 100644 test/ios/mocked_data/test_get_network_instances/no_vrf/expected_result.json create mode 100644 test/ios/mocked_data/test_get_network_instances/no_vrf/show_ip_interface_brief.txt create mode 100644 test/ios/mocked_data/test_get_network_instances/no_vrf/show_vrf_detail.txt diff --git a/test/ios/mocked_data/test_get_network_instances/no_vrf/expected_result.json b/test/ios/mocked_data/test_get_network_instances/no_vrf/expected_result.json new file mode 100644 index 000000000..2162b497b --- /dev/null +++ b/test/ios/mocked_data/test_get_network_instances/no_vrf/expected_result.json @@ -0,0 +1,29 @@ +{ + "default": { + "name": "default", + "type": "DEFAULT_INSTANCE", + "state": { + "route_distinguisher": "" + }, + "interfaces": { + "interface": { + "Ethernet0/0": {}, + "Ethernet0/1": {}, + "Ethernet0/2": {}, + "Ethernet0/3": {}, + "Ethernet1/0": {}, + "Ethernet1/1": {}, + "Ethernet1/2": {}, + "Ethernet1/3": {}, + "Serial2/0": {}, + "Serial2/1": {}, + "Serial2/2": {}, + "Serial2/3": {}, + "Serial3/0": {}, + "Serial3/1": {}, + "Serial3/2": {}, + "Serial3/3": {} + } + } + } +} diff --git a/test/ios/mocked_data/test_get_network_instances/no_vrf/show_ip_interface_brief.txt b/test/ios/mocked_data/test_get_network_instances/no_vrf/show_ip_interface_brief.txt new file mode 100644 index 000000000..a10a23944 --- /dev/null +++ b/test/ios/mocked_data/test_get_network_instances/no_vrf/show_ip_interface_brief.txt @@ -0,0 +1,17 @@ +Interface IP-Address OK? Method Status Protocol +Ethernet0/0 172.29.29.201 YES manual up up +Ethernet0/1 100.100.100.100 YES manual up up +Ethernet0/2 unassigned YES NVRAM administratively down down +Ethernet0/3 unassigned YES NVRAM administratively down down +Ethernet1/0 unassigned YES NVRAM administratively down down +Ethernet1/1 unassigned YES NVRAM administratively down down +Ethernet1/2 unassigned YES NVRAM administratively down down +Ethernet1/3 unassigned YES NVRAM up up +Serial2/0 unassigned YES NVRAM administratively down down +Serial2/1 unassigned YES NVRAM administratively down down +Serial2/2 unassigned YES NVRAM administratively down down +Serial2/3 unassigned YES NVRAM administratively down down +Serial3/0 unassigned YES NVRAM administratively down down +Serial3/1 unassigned YES NVRAM administratively down down +Serial3/2 unassigned YES NVRAM administratively down down +Serial3/3 unassigned YES NVRAM administratively down down diff --git a/test/ios/mocked_data/test_get_network_instances/no_vrf/show_vrf_detail.txt b/test/ios/mocked_data/test_get_network_instances/no_vrf/show_vrf_detail.txt new file mode 100644 index 000000000..e69de29bb diff --git a/test/ios/mocked_data/test_get_network_instances/normal/expected_result.json b/test/ios/mocked_data/test_get_network_instances/normal/expected_result.json index ce1c42502..3fa72cc63 100644 --- a/test/ios/mocked_data/test_get_network_instances/normal/expected_result.json +++ b/test/ios/mocked_data/test_get_network_instances/normal/expected_result.json @@ -1,78 +1,51 @@ { - "default":{ - "interfaces":{ - "interface":{ - "GigabitEthernet0/0/0":{ - - }, - "Gi0/0/0.152":{ - - }, - "GigabitEthernet0/0/2":{ - - }, - "Gi0/0/0.1774":{ - - }, - "GigabitEthernet0/0/4":{ - - }, - "Gi0/0/0.1772":{ - - }, - "GigabitEthernet0/0/3":{ - - }, - "Gi0/0/0.154":{ - - }, - "GigabitEthernet0/0/1":{ - - }, - "GigabitEthernet0":{ - - }, - "Gi0/0/0.1776":{ - - }, - "Gi0/0/0.600":{ - - }, - "Loopback2":{ - - } - } - }, - "state":{ - "route_distinguisher":"" - }, - "type":"DEFAULT_INSTANCE", - "name":"default" + "default": { + "name": "default", + "type": "DEFAULT_INSTANCE", + "state": { + "route_distinguisher": "" + }, + "interfaces": { + "interface": { + "Ethernet0/0": {}, + "Ethernet0/2": {}, + "Ethernet0/3": {}, + "Ethernet1/0": {}, + "Ethernet1/1": {}, + "Ethernet1/2": {}, + "Serial2/0": {}, + "Serial2/1": {}, + "Serial2/2": {}, + "Serial2/3": {}, + "Serial3/0": {}, + "Serial3/1": {}, + "Serial3/2": {}, + "Serial3/3": {} + } + } }, - "Mgmt-intf":{ - "interfaces":{ - "interface":{ - "Gi0":{ - - } - } - }, - "state":{ - "route_distinguisher":"" - }, - "type":"L3VRF", - "name":"Mgmt-intf" + "CustA": { + "name": "CustA", + "type": "L3VRF", + "state": { + "route_distinguisher": "2:2" + }, + "interfaces": { + "interface": { + "Ethernet0/1": {} + } + } }, - "opsnet":{ - "interfaces":{ - "interface":{ - - } - }, - "state":{ - "route_distinguisher":"10283:1021312690" - }, - "type":"L3VRF", - "name":"opsnet" + "mgmt": { + "name": "mgmt", + "type": "L3VRF", + "state": { + "route_distinguisher": "100:100" + }, + "interfaces": { + "interface": { + "Ethernet1/3": {} + } + } } -} \ No newline at end of file +} diff --git a/test/ios/mocked_data/test_get_network_instances/normal/show_ip_interface_brief.txt b/test/ios/mocked_data/test_get_network_instances/normal/show_ip_interface_brief.txt index 8ef3917eb..f2c3e361a 100644 --- a/test/ios/mocked_data/test_get_network_instances/normal/show_ip_interface_brief.txt +++ b/test/ios/mocked_data/test_get_network_instances/normal/show_ip_interface_brief.txt @@ -1,17 +1,17 @@ -Load for five secs: 0%/0%; one minute: 1%; five minutes: 1% -Time source is NTP, 09:30:03.851 DST Wed Nov 8 2017 - -Interface IP-Address OK? Method Status Protocol -GigabitEthernet0/0/0 unassigned YES NVRAM up up -Gi0/0/0.152 192.168.241.21 YES NVRAM up up -Gi0/0/0.154 192.168.241.30 YES NVRAM up up -Gi0/0/0.600 192.168.241.141 YES NVRAM up up -Gi0/0/0.1772 120.177.177.1 YES NVRAM up up -Gi0/0/0.1774 101.177.177.1 YES NVRAM up up -Gi0/0/0.1776 100.177.177.1 YES NVRAM up up -GigabitEthernet0/0/1 unassigned YES NVRAM administratively down down -GigabitEthernet0/0/2 unassigned YES NVRAM administratively down down -GigabitEthernet0/0/3 unassigned YES NVRAM administratively down down -GigabitEthernet0/0/4 unassigned YES NVRAM administratively down down -GigabitEthernet0 192.168.243.80 YES NVRAM up up -Loopback2 192.168.242.152 YES NVRAM up up \ No newline at end of file +Interface IP-Address OK? Method Status Protocol +Ethernet0/0 172.29.29.200 YES NVRAM up up +Ethernet0/1 10.50.50.1 YES NVRAM up up +Ethernet0/2 unassigned YES NVRAM administratively down down +Ethernet0/3 unassigned YES NVRAM administratively down down +Ethernet1/0 unassigned YES NVRAM administratively down down +Ethernet1/1 unassigned YES NVRAM administratively down down +Ethernet1/2 unassigned YES NVRAM administratively down down +Ethernet1/3 172.20.20.20 YES NVRAM up up +Serial2/0 unassigned YES NVRAM administratively down down +Serial2/1 unassigned YES NVRAM administratively down down +Serial2/2 unassigned YES NVRAM administratively down down +Serial2/3 unassigned YES NVRAM administratively down down +Serial3/0 unassigned YES NVRAM administratively down down +Serial3/1 unassigned YES NVRAM administratively down down +Serial3/2 unassigned YES NVRAM administratively down down +Serial3/3 unassigned YES NVRAM administratively down down diff --git a/test/ios/mocked_data/test_get_network_instances/normal/show_vrf_detail.txt b/test/ios/mocked_data/test_get_network_instances/normal/show_vrf_detail.txt index f29e9a0f9..02a913358 100644 --- a/test/ios/mocked_data/test_get_network_instances/normal/show_vrf_detail.txt +++ b/test/ios/mocked_data/test_get_network_instances/normal/show_vrf_detail.txt @@ -1,11 +1,8 @@ -Load for five secs: 0%/0%; one minute: 0%; five minutes: 1% -Time source is NTP, 09:28:50.737 DST Wed Nov 8 2017 - -VRF Mgmt-intf (VRF Id = 1); default RD ; default VPNID +VRF CustA (VRF Id = 1); default RD 2:2; default VPNID New CLI format, supports multiple address-families - Flags: 0x1808 + Flags: 0x180C Interfaces: - Gi0 + Et0/1 Address family ipv4 unicast (Table ID = 0x1): Flags: 0x0 No Export VPN route-target communities @@ -15,31 +12,22 @@ Address family ipv4 unicast (Table ID = 0x1): No export route-map VRF label distribution protocol: not configured VRF label allocation mode: per-prefix -Address family ipv6 unicast (Table ID = 0x1E000001): - Flags: 0x0 - No Export VPN route-target communities - No Import VPN route-target communities - No import route-map - No global export route-map - No export route-map - VRF label distribution protocol: not configured - VRF label allocation mode: per-prefix +Address family ipv6 unicast not active Address family ipv4 multicast not active -VRF opsnet (VRF Id = 2); default RD 10283:1021312690; default VPNID +VRF mgmt (VRF Id = 2); default RD 100:100; default VPNID New CLI format, supports multiple address-families Flags: 0x180C - No interfaces + Interfaces: + Et1/3 Address family ipv4 unicast (Table ID = 0x2): Flags: 0x0 - Export VPN route-target communities - RT:10283:50000 - Import VPN route-target communities - RT:10283:50000 + No Export VPN route-target communities + No Import VPN route-target communities No import route-map No global export route-map No export route-map VRF label distribution protocol: not configured VRF label allocation mode: per-prefix Address family ipv6 unicast not active -Address family ipv4 multicast not active \ No newline at end of file +Address family ipv4 multicast not active From 35b84fb72fb328c8e3a5dc5e0302f953934e4a2c Mon Sep 17 00:00:00 2001 From: chonty Date: Wed, 5 Aug 2020 23:30:27 +1000 Subject: [PATCH 14/23] as_path fix for internally generated prefixes --- napalm/ios/ios.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/napalm/ios/ios.py b/napalm/ios/ios.py index 25d93e525..95271d047 100644 --- a/napalm/ios/ios.py +++ b/napalm/ios/ios.py @@ -2766,7 +2766,7 @@ def _get_bgp_route_attr(self, destination, vrf, next_hop, ip_version=4): search_re_dict = { "aspath": { - "re": r"[^|\\n][ ]{2}([\d\(\)]([\d\(\) ])*)", + "re": r"[^|\\n][ ]{2}([\d\(\)]([\d\(\) ])*|Local)", "group": 1, "default": "", }, From 08805511a063cd028b4c07084bc7cdac77344824 Mon Sep 17 00:00:00 2001 From: chonty Date: Wed, 5 Aug 2020 23:52:25 +1000 Subject: [PATCH 15/23] test data --- .../non_exact/expected_result.json | 68 +++++++++++++++++++ .../non_exact/show_ip_bgp_10_50_50_0.txt | 9 +++ ...p_neighbors___include_is_200_200_200_1.txt | 1 + ...show_ip_bgp_vpnv4_vrf_CustA_10_50_50_0.txt | 8 +++ ...A_neighbors___include_is_169_254_255_1.txt | 1 + ...show_ip_bgp_vpnv4_vrf_CustB_10_50_50_0.txt | 8 +++ ...B_neighbors___include_is_169_254_255_1.txt | 1 + .../show_ip_protocols___include_bgp.txt | 1 + .../non_exact/show_ip_route_10_50_50_0.txt | 10 +++ .../show_ip_route_vrf_CustA_10_50_50_0.txt | 10 +++ .../show_ip_route_vrf_CustB_10_50_50_0.txt | 10 +++ .../test_get_route_to/non_exact/show_vrf.txt | 3 + 12 files changed, 130 insertions(+) create mode 100644 test/ios/mocked_data/test_get_route_to/non_exact/expected_result.json create mode 100644 test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_10_50_50_0.txt create mode 100644 test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_neighbors___include_is_200_200_200_1.txt create mode 100644 test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustA_10_50_50_0.txt create mode 100644 test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustA_neighbors___include_is_169_254_255_1.txt create mode 100644 test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustB_10_50_50_0.txt create mode 100644 test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustB_neighbors___include_is_169_254_255_1.txt create mode 100644 test/ios/mocked_data/test_get_route_to/non_exact/show_ip_protocols___include_bgp.txt create mode 100644 test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_10_50_50_0.txt create mode 100644 test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_vrf_CustA_10_50_50_0.txt create mode 100644 test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_vrf_CustB_10_50_50_0.txt create mode 100644 test/ios/mocked_data/test_get_route_to/non_exact/show_vrf.txt diff --git a/test/ios/mocked_data/test_get_route_to/non_exact/expected_result.json b/test/ios/mocked_data/test_get_route_to/non_exact/expected_result.json new file mode 100644 index 000000000..b72e3ea15 --- /dev/null +++ b/test/ios/mocked_data/test_get_route_to/non_exact/expected_result.json @@ -0,0 +1,68 @@ +{ + "10.50.50.0/23": [ + { + "protocol": "bgp", + "outgoing_interface": "", + "age": 722, + "current_active": true, + "routing_table": "CustA", + "last_active": true, + "protocol_attributes": { + "as_path": "Local", + "remote_address": "169.254.255.1", + "communities": [], + "local_preference": 100, + "local_as": 1, + "remote_as": 1 + }, + "next_hop": "169.254.255.1", + "selected_next_hop": true, + "inactive_reason": "", + "preference": 0 + } + ], + "10.50.50.0/24": [ + { + "protocol": "bgp", + "outgoing_interface": "", + "age": 722, + "current_active": true, + "routing_table": "CustB", + "last_active": true, + "protocol_attributes": { + "as_path": "Local", + "remote_address": "169.254.255.1", + "communities": [], + "local_preference": 100, + "local_as": 1, + "remote_as": 1 + }, + "next_hop": "169.254.255.1", + "selected_next_hop": true, + "inactive_reason": "", + "preference": 0 + } + ], + "10.50.0.0/16": [ + { + "protocol": "bgp", + "outgoing_interface": "", + "age": 22, + "current_active": true, + "routing_table": "default", + "last_active": true, + "protocol_attributes": { + "as_path": "3 3 3 3", + "remote_address": "200.200.200.1", + "communities": [], + "local_preference": 100, + "local_as": 1, + "remote_as": 3 + }, + "next_hop": "200.200.200.1", + "selected_next_hop": true, + "inactive_reason": "", + "preference": 0 + } + ] +} diff --git a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_10_50_50_0.txt b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_10_50_50_0.txt new file mode 100644 index 000000000..62a724467 --- /dev/null +++ b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_10_50_50_0.txt @@ -0,0 +1,9 @@ +BGP routing table entry for 10.50.50.0/24, version 2 +Paths: (1 available, best #1, table default) + Advertised to update-groups: + 2 + Refresh Epoch 1 + 3 3 3 3 + 200.200.200.1 from 200.200.200.1 (1.1.1.1) + Origin IGP, metric 0, localpref 100, valid, external, best + rx pathid: 0, tx pathid: 0x0 diff --git a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_neighbors___include_is_200_200_200_1.txt b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_neighbors___include_is_200_200_200_1.txt new file mode 100644 index 000000000..6ee579e97 --- /dev/null +++ b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_neighbors___include_is_200_200_200_1.txt @@ -0,0 +1 @@ +BGP neighbor is 200.200.200.1, remote AS 3, local AS 2 no-prepend replace-as, external link diff --git a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustA_10_50_50_0.txt b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustA_10_50_50_0.txt new file mode 100644 index 000000000..e7ea0cfde --- /dev/null +++ b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustA_10_50_50_0.txt @@ -0,0 +1,8 @@ +BGP routing table entry for 2:2:10.50.50.0/23, version 2 +Paths: (1 available, best #1, table CustA) + Not advertised to any peer + Refresh Epoch 1 + Local + 169.254.255.1 (via vrf CustA) from 169.254.255.1 (1.1.1.1) + Origin IGP, metric 0, localpref 100, valid, internal, best + rx pathid: 0, tx pathid: 0x0 diff --git a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustA_neighbors___include_is_169_254_255_1.txt b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustA_neighbors___include_is_169_254_255_1.txt new file mode 100644 index 000000000..ab594d932 --- /dev/null +++ b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustA_neighbors___include_is_169_254_255_1.txt @@ -0,0 +1 @@ +BGP neighbor is 169.254.255.1, vrf CustA, remote AS 1, internal link diff --git a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustB_10_50_50_0.txt b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustB_10_50_50_0.txt new file mode 100644 index 000000000..114de91ec --- /dev/null +++ b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustB_10_50_50_0.txt @@ -0,0 +1,8 @@ +BGP routing table entry for 3:3:10.50.50.0/24, version 3 +Paths: (1 available, best #1, table CustB) + Not advertised to any peer + Refresh Epoch 1 + Local + 169.254.255.1 (via vrf CustB) from 169.254.255.1 (1.1.1.1) + Origin IGP, metric 0, localpref 100, valid, internal, best + rx pathid: 0, tx pathid: 0x0 diff --git a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustB_neighbors___include_is_169_254_255_1.txt b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustB_neighbors___include_is_169_254_255_1.txt new file mode 100644 index 000000000..7c70cf487 --- /dev/null +++ b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustB_neighbors___include_is_169_254_255_1.txt @@ -0,0 +1 @@ +BGP neighbor is 169.254.255.1, vrf CustB, remote AS 1, internal link diff --git a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_protocols___include_bgp.txt b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_protocols___include_bgp.txt new file mode 100644 index 000000000..87aa166dc --- /dev/null +++ b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_protocols___include_bgp.txt @@ -0,0 +1 @@ +Routing Protocol is "bgp 1" diff --git a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_10_50_50_0.txt b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_10_50_50_0.txt new file mode 100644 index 000000000..415ec83a1 --- /dev/null +++ b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_10_50_50_0.txt @@ -0,0 +1,10 @@ +Routing entry for 10.50.50.0/24 + Known via "bgp 1", distance 20, metric 0 + Tag 3, type external + Last update from 200.200.200.1 00:01:02 ago + Routing Descriptor Blocks: + * 200.200.200.1, from 200.200.200.1, 00:01:02 ago + Route metric is 0, traffic share count is 1 + AS Hops 4 + Route tag 3 + MPLS label: none diff --git a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_vrf_CustA_10_50_50_0.txt b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_vrf_CustA_10_50_50_0.txt new file mode 100644 index 000000000..368d82f56 --- /dev/null +++ b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_vrf_CustA_10_50_50_0.txt @@ -0,0 +1,10 @@ + +Routing Table: CustA +Routing entry for 10.50.50.0/23 + Known via "bgp 1", distance 200, metric 0, type internal + Last update from 169.254.255.1 00:01:48 ago + Routing Descriptor Blocks: + * 169.254.255.1, from 169.254.255.1, 00:01:48 ago + Route metric is 0, traffic share count is 1 + AS Hops 0 + MPLS label: none diff --git a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_vrf_CustB_10_50_50_0.txt b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_vrf_CustB_10_50_50_0.txt new file mode 100644 index 000000000..1cedd6a15 --- /dev/null +++ b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_vrf_CustB_10_50_50_0.txt @@ -0,0 +1,10 @@ + +Routing Table: CustB +Routing entry for 10.50.50.0/24 + Known via "bgp 1", distance 200, metric 0, type internal + Last update from 169.254.255.1 00:01:38 ago + Routing Descriptor Blocks: + * 169.254.255.1, from 169.254.255.1, 00:01:38 ago + Route metric is 0, traffic share count is 1 + AS Hops 0 + MPLS label: none diff --git a/test/ios/mocked_data/test_get_route_to/non_exact/show_vrf.txt b/test/ios/mocked_data/test_get_route_to/non_exact/show_vrf.txt new file mode 100644 index 000000000..dd96083fa --- /dev/null +++ b/test/ios/mocked_data/test_get_route_to/non_exact/show_vrf.txt @@ -0,0 +1,3 @@ + Name Default RD Protocols Interfaces + CustA 2:2 ipv4 Et0/1 + CustB 3:3 ipv4 Et0/2 From 71ffa5179535ec5f4d09f9df688e78d703986f68 Mon Sep 17 00:00:00 2001 From: chonty Date: Thu, 6 Aug 2020 00:09:52 +1000 Subject: [PATCH 16/23] updated test cases --- .../no_vrf_svis/expected_result.json | 33 ++++++++++ .../no_vrf_svis/show_ip_interface_brief.txt | 21 ++++++ .../no_vrf_svis/show_vrf_detail.txt | 0 .../normal_svis/expected_result.json | 66 +++++++++++++++++++ .../normal_svis/show_ip_interface_brief.txt | 21 ++++++ .../normal_svis/show_vrf_detail.txt | 48 ++++++++++++++ 6 files changed, 189 insertions(+) create mode 100644 test/ios/mocked_data/test_get_network_instances/no_vrf_svis/expected_result.json create mode 100644 test/ios/mocked_data/test_get_network_instances/no_vrf_svis/show_ip_interface_brief.txt create mode 100644 test/ios/mocked_data/test_get_network_instances/no_vrf_svis/show_vrf_detail.txt create mode 100644 test/ios/mocked_data/test_get_network_instances/normal_svis/expected_result.json create mode 100644 test/ios/mocked_data/test_get_network_instances/normal_svis/show_ip_interface_brief.txt create mode 100644 test/ios/mocked_data/test_get_network_instances/normal_svis/show_vrf_detail.txt diff --git a/test/ios/mocked_data/test_get_network_instances/no_vrf_svis/expected_result.json b/test/ios/mocked_data/test_get_network_instances/no_vrf_svis/expected_result.json new file mode 100644 index 000000000..6e995be8d --- /dev/null +++ b/test/ios/mocked_data/test_get_network_instances/no_vrf_svis/expected_result.json @@ -0,0 +1,33 @@ +{ + "default": { + "name": "default", + "type": "DEFAULT_INSTANCE", + "state": { + "route_distinguisher": "" + }, + "interfaces": { + "interface": { + "Ethernet0/0": {}, + "Ethernet0/1": {}, + "Ethernet0/2": {}, + "Ethernet0/3": {}, + "Ethernet1/0": {}, + "Ethernet1/1": {}, + "Ethernet1/2": {}, + "Ethernet1/3": {}, + "Ethernet2/0": {}, + "Ethernet2/1": {}, + "Ethernet2/2": {}, + "Ethernet2/3": {}, + "Ethernet3/0": {}, + "Ethernet3/1": {}, + "Ethernet3/2": {}, + "Ethernet3/3": {}, + "Vlan1": {}, + "Vlan2": {}, + "Vlan3": {}, + "Vlan4": {} + } + } + } +} diff --git a/test/ios/mocked_data/test_get_network_instances/no_vrf_svis/show_ip_interface_brief.txt b/test/ios/mocked_data/test_get_network_instances/no_vrf_svis/show_ip_interface_brief.txt new file mode 100644 index 000000000..fcee66929 --- /dev/null +++ b/test/ios/mocked_data/test_get_network_instances/no_vrf_svis/show_ip_interface_brief.txt @@ -0,0 +1,21 @@ +Interface IP-Address OK? Method Status Protocol +Ethernet0/0 172.29.29.220 YES manual up up +Ethernet0/1 unassigned YES unset up up +Ethernet0/2 unassigned YES unset up up +Ethernet0/3 unassigned YES unset up up +Ethernet1/0 unassigned YES unset up up +Ethernet1/1 unassigned YES unset up up +Ethernet1/2 unassigned YES unset up up +Ethernet1/3 unassigned YES unset up up +Ethernet2/0 unassigned YES unset up up +Ethernet2/1 unassigned YES unset up up +Ethernet2/2 unassigned YES unset up up +Ethernet2/3 unassigned YES unset up up +Ethernet3/0 unassigned YES unset up up +Ethernet3/1 unassigned YES unset up up +Ethernet3/2 unassigned YES unset up up +Ethernet3/3 unassigned YES unset up up +Vlan1 unassigned YES unset administratively down down +Vlan2 2.2.2.2 YES manual up up +Vlan3 3.3.3.3 YES manual up up +Vlan4 4.4.4.4 YES manual up up diff --git a/test/ios/mocked_data/test_get_network_instances/no_vrf_svis/show_vrf_detail.txt b/test/ios/mocked_data/test_get_network_instances/no_vrf_svis/show_vrf_detail.txt new file mode 100644 index 000000000..e69de29bb diff --git a/test/ios/mocked_data/test_get_network_instances/normal_svis/expected_result.json b/test/ios/mocked_data/test_get_network_instances/normal_svis/expected_result.json new file mode 100644 index 000000000..3a0e182dd --- /dev/null +++ b/test/ios/mocked_data/test_get_network_instances/normal_svis/expected_result.json @@ -0,0 +1,66 @@ +{ + "default": { + "name": "default", + "type": "DEFAULT_INSTANCE", + "state": { + "route_distinguisher": "" + }, + "interfaces": { + "interface": { + "Ethernet0/0": {}, + "Ethernet0/1": {}, + "Ethernet0/2": {}, + "Ethernet0/3": {}, + "Ethernet1/0": {}, + "Ethernet1/1": {}, + "Ethernet1/2": {}, + "Ethernet1/3": {}, + "Ethernet2/0": {}, + "Ethernet2/1": {}, + "Ethernet2/2": {}, + "Ethernet2/3": {}, + "Ethernet3/0": {}, + "Ethernet3/1": {}, + "Ethernet3/2": {}, + "Ethernet3/3": {}, + "Vlan1": {} + } + } + }, + "CustA": { + "name": "CustA", + "type": "L3VRF", + "state": { + "route_distinguisher": "1:1" + }, + "interfaces": { + "interface": { + "Vlan2": {} + } + } + }, + "CustB": { + "name": "CustB", + "type": "L3VRF", + "state": { + "route_distinguisher": "2:2" + }, + "interfaces": { + "interface": { + "Vlan3": {} + } + } + }, + "CustC": { + "name": "CustC", + "type": "L3VRF", + "state": { + "route_distinguisher": "3:3" + }, + "interfaces": { + "interface": { + "Vlan4": {} + } + } + } +} diff --git a/test/ios/mocked_data/test_get_network_instances/normal_svis/show_ip_interface_brief.txt b/test/ios/mocked_data/test_get_network_instances/normal_svis/show_ip_interface_brief.txt new file mode 100644 index 000000000..fcee66929 --- /dev/null +++ b/test/ios/mocked_data/test_get_network_instances/normal_svis/show_ip_interface_brief.txt @@ -0,0 +1,21 @@ +Interface IP-Address OK? Method Status Protocol +Ethernet0/0 172.29.29.220 YES manual up up +Ethernet0/1 unassigned YES unset up up +Ethernet0/2 unassigned YES unset up up +Ethernet0/3 unassigned YES unset up up +Ethernet1/0 unassigned YES unset up up +Ethernet1/1 unassigned YES unset up up +Ethernet1/2 unassigned YES unset up up +Ethernet1/3 unassigned YES unset up up +Ethernet2/0 unassigned YES unset up up +Ethernet2/1 unassigned YES unset up up +Ethernet2/2 unassigned YES unset up up +Ethernet2/3 unassigned YES unset up up +Ethernet3/0 unassigned YES unset up up +Ethernet3/1 unassigned YES unset up up +Ethernet3/2 unassigned YES unset up up +Ethernet3/3 unassigned YES unset up up +Vlan1 unassigned YES unset administratively down down +Vlan2 2.2.2.2 YES manual up up +Vlan3 3.3.3.3 YES manual up up +Vlan4 4.4.4.4 YES manual up up diff --git a/test/ios/mocked_data/test_get_network_instances/normal_svis/show_vrf_detail.txt b/test/ios/mocked_data/test_get_network_instances/normal_svis/show_vrf_detail.txt new file mode 100644 index 000000000..e7875737b --- /dev/null +++ b/test/ios/mocked_data/test_get_network_instances/normal_svis/show_vrf_detail.txt @@ -0,0 +1,48 @@ +VRF CustA (VRF Id = 1); default RD 1:1; default VPNID + New CLI format, supports multiple address-families + Flags: 0x180C + Interfaces: + Vl2 +Address family ipv4 unicast (Table ID = 0x1): + Flags: 0x0 + No Export VPN route-target communities + No Import VPN route-target communities + No import route-map + No global export route-map + No export route-map + VRF label distribution protocol: not configured + VRF label allocation mode: per-prefix +Address family ipv6 unicast not active + +VRF CustB (VRF Id = 2); default RD 2:2; default VPNID + New CLI format, supports multiple address-families + Flags: 0x180C + Interfaces: + Vl3 +Address family ipv4 unicast (Table ID = 0x2): + Flags: 0x0 + No Export VPN route-target communities + No Import VPN route-target communities + No import route-map + No global export route-map + No export route-map + VRF label distribution protocol: not configured + VRF label allocation mode: per-prefix +Address family ipv6 unicast not active + +VRF CustC (VRF Id = 3); default RD 3:3; default VPNID + New CLI format, supports multiple address-families + Flags: 0x180C + Interfaces: + Vl4 +Address family ipv4 unicast (Table ID = 0x3): + Flags: 0x0 + No Export VPN route-target communities + No Import VPN route-target communities + No import route-map + No global export route-map + No export route-map + VRF label distribution protocol: not configured + VRF label allocation mode: per-prefix +Address family ipv6 unicast not active + From 4dff67c5364c7db2f5240e7af802dc76bd6b8902 Mon Sep 17 00:00:00 2001 From: chonty Date: Thu, 6 Aug 2020 00:15:25 +1000 Subject: [PATCH 17/23] reverted original test case changes --- .../no_vrf/expected_result.json | 29 ----- .../no_vrf/show_ip_interface_brief.txt | 17 --- .../no_vrf/show_vrf_detail.txt | 0 .../normal/expected_result.json | 100 ++++++++++-------- .../normal/show_ip_interface_brief.txt | 34 +++--- .../normal/show_vrf_detail.txt | 48 +++------ 6 files changed, 89 insertions(+), 139 deletions(-) delete mode 100644 test/ios/mocked_data/test_get_network_instances/no_vrf/expected_result.json delete mode 100644 test/ios/mocked_data/test_get_network_instances/no_vrf/show_ip_interface_brief.txt delete mode 100644 test/ios/mocked_data/test_get_network_instances/no_vrf/show_vrf_detail.txt diff --git a/test/ios/mocked_data/test_get_network_instances/no_vrf/expected_result.json b/test/ios/mocked_data/test_get_network_instances/no_vrf/expected_result.json deleted file mode 100644 index 2162b497b..000000000 --- a/test/ios/mocked_data/test_get_network_instances/no_vrf/expected_result.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "default": { - "name": "default", - "type": "DEFAULT_INSTANCE", - "state": { - "route_distinguisher": "" - }, - "interfaces": { - "interface": { - "Ethernet0/0": {}, - "Ethernet0/1": {}, - "Ethernet0/2": {}, - "Ethernet0/3": {}, - "Ethernet1/0": {}, - "Ethernet1/1": {}, - "Ethernet1/2": {}, - "Ethernet1/3": {}, - "Serial2/0": {}, - "Serial2/1": {}, - "Serial2/2": {}, - "Serial2/3": {}, - "Serial3/0": {}, - "Serial3/1": {}, - "Serial3/2": {}, - "Serial3/3": {} - } - } - } -} diff --git a/test/ios/mocked_data/test_get_network_instances/no_vrf/show_ip_interface_brief.txt b/test/ios/mocked_data/test_get_network_instances/no_vrf/show_ip_interface_brief.txt deleted file mode 100644 index a10a23944..000000000 --- a/test/ios/mocked_data/test_get_network_instances/no_vrf/show_ip_interface_brief.txt +++ /dev/null @@ -1,17 +0,0 @@ -Interface IP-Address OK? Method Status Protocol -Ethernet0/0 172.29.29.201 YES manual up up -Ethernet0/1 100.100.100.100 YES manual up up -Ethernet0/2 unassigned YES NVRAM administratively down down -Ethernet0/3 unassigned YES NVRAM administratively down down -Ethernet1/0 unassigned YES NVRAM administratively down down -Ethernet1/1 unassigned YES NVRAM administratively down down -Ethernet1/2 unassigned YES NVRAM administratively down down -Ethernet1/3 unassigned YES NVRAM up up -Serial2/0 unassigned YES NVRAM administratively down down -Serial2/1 unassigned YES NVRAM administratively down down -Serial2/2 unassigned YES NVRAM administratively down down -Serial2/3 unassigned YES NVRAM administratively down down -Serial3/0 unassigned YES NVRAM administratively down down -Serial3/1 unassigned YES NVRAM administratively down down -Serial3/2 unassigned YES NVRAM administratively down down -Serial3/3 unassigned YES NVRAM administratively down down diff --git a/test/ios/mocked_data/test_get_network_instances/no_vrf/show_vrf_detail.txt b/test/ios/mocked_data/test_get_network_instances/no_vrf/show_vrf_detail.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/ios/mocked_data/test_get_network_instances/normal/expected_result.json b/test/ios/mocked_data/test_get_network_instances/normal/expected_result.json index 3fa72cc63..d362f99c4 100644 --- a/test/ios/mocked_data/test_get_network_instances/normal/expected_result.json +++ b/test/ios/mocked_data/test_get_network_instances/normal/expected_result.json @@ -1,51 +1,63 @@ { - "default": { - "name": "default", - "type": "DEFAULT_INSTANCE", - "state": { - "route_distinguisher": "" + "Mgmt-intf":{ + "name":"Mgmt-intf", + "type":"L3VRF", + "state":{ + "route_distinguisher":"" }, - "interfaces": { - "interface": { - "Ethernet0/0": {}, - "Ethernet0/2": {}, - "Ethernet0/3": {}, - "Ethernet1/0": {}, - "Ethernet1/1": {}, - "Ethernet1/2": {}, - "Serial2/0": {}, - "Serial2/1": {}, - "Serial2/2": {}, - "Serial2/3": {}, - "Serial3/0": {}, - "Serial3/1": {}, - "Serial3/2": {}, - "Serial3/3": {} - } + "interfaces":{ + "Gi0":{ + + } } - }, - "CustA": { - "name": "CustA", - "type": "L3VRF", - "state": { - "route_distinguisher": "2:2" + }, + "Aut622":{ + "name":"Aut622", + "type":"L3VRF", + "state":{ + "route_distinguisher":"65421:224" }, - "interfaces": { - "interface": { - "Ethernet0/1": {} - } + "interfaces":{ + "Te2/0/0.622":{ + + }, + "Lo622":{ + + } } - }, - "mgmt": { - "name": "mgmt", - "type": "L3VRF", - "state": { - "route_distinguisher": "100:100" + }, + "mipepa33":{ + "name":"mipepa33", + "type":"L3VRF", + "state":{ + "route_distinguisher":"65421:942133" }, - "interfaces": { - "interface": { - "Ethernet1/3": {} - } + "interfaces":{ + "Lo199":{ + + }, + "Te2/0/0.1919":{ + + }, + "Tu0":{ + + }, + "Tu4":{ + + }, + "Tu6":{ + + } } - } -} + }, + "vrf101":{ + "name":"vrf101", + "type":"L3VRF", + "state":{ + "route_distinguisher":"65421:55101" + }, + "interfaces":{ + + } + } + } diff --git a/test/ios/mocked_data/test_get_network_instances/normal/show_ip_interface_brief.txt b/test/ios/mocked_data/test_get_network_instances/normal/show_ip_interface_brief.txt index f2c3e361a..84162f9a8 100644 --- a/test/ios/mocked_data/test_get_network_instances/normal/show_ip_interface_brief.txt +++ b/test/ios/mocked_data/test_get_network_instances/normal/show_ip_interface_brief.txt @@ -1,17 +1,17 @@ -Interface IP-Address OK? Method Status Protocol -Ethernet0/0 172.29.29.200 YES NVRAM up up -Ethernet0/1 10.50.50.1 YES NVRAM up up -Ethernet0/2 unassigned YES NVRAM administratively down down -Ethernet0/3 unassigned YES NVRAM administratively down down -Ethernet1/0 unassigned YES NVRAM administratively down down -Ethernet1/1 unassigned YES NVRAM administratively down down -Ethernet1/2 unassigned YES NVRAM administratively down down -Ethernet1/3 172.20.20.20 YES NVRAM up up -Serial2/0 unassigned YES NVRAM administratively down down -Serial2/1 unassigned YES NVRAM administratively down down -Serial2/2 unassigned YES NVRAM administratively down down -Serial2/3 unassigned YES NVRAM administratively down down -Serial3/0 unassigned YES NVRAM administratively down down -Serial3/1 unassigned YES NVRAM administratively down down -Serial3/2 unassigned YES NVRAM administratively down down -Serial3/3 unassigned YES NVRAM administratively down down +Load for five secs: 0%/0%; one minute: 1%; five minutes: 1% +Time source is NTP, 09:30:03.851 DST Wed Nov 8 2017 + +Interface IP-Address OK? Method Status Protocol +GigabitEthernet0/0/0 unassigned YES NVRAM up up +Gi0/0/0.152 192.168.241.21 YES NVRAM up up +Gi0/0/0.154 192.168.241.30 YES NVRAM up up +Gi0/0/0.600 192.168.241.141 YES NVRAM up up +Gi0/0/0.1772 120.177.177.1 YES NVRAM up up +Gi0/0/0.1774 101.177.177.1 YES NVRAM up up +Gi0/0/0.1776 100.177.177.1 YES NVRAM up up +GigabitEthernet0/0/1 unassigned YES NVRAM administratively down down +GigabitEthernet0/0/2 unassigned YES NVRAM administratively down down +GigabitEthernet0/0/3 unassigned YES NVRAM administratively down down +GigabitEthernet0/0/4 unassigned YES NVRAM administratively down down +GigabitEthernet0 192.168.243.80 YES NVRAM up up +Loopback2 192.168.242.152 YES NVRAM up up diff --git a/test/ios/mocked_data/test_get_network_instances/normal/show_vrf_detail.txt b/test/ios/mocked_data/test_get_network_instances/normal/show_vrf_detail.txt index 02a913358..84162f9a8 100644 --- a/test/ios/mocked_data/test_get_network_instances/normal/show_vrf_detail.txt +++ b/test/ios/mocked_data/test_get_network_instances/normal/show_vrf_detail.txt @@ -1,33 +1,17 @@ -VRF CustA (VRF Id = 1); default RD 2:2; default VPNID - New CLI format, supports multiple address-families - Flags: 0x180C - Interfaces: - Et0/1 -Address family ipv4 unicast (Table ID = 0x1): - Flags: 0x0 - No Export VPN route-target communities - No Import VPN route-target communities - No import route-map - No global export route-map - No export route-map - VRF label distribution protocol: not configured - VRF label allocation mode: per-prefix -Address family ipv6 unicast not active -Address family ipv4 multicast not active +Load for five secs: 0%/0%; one minute: 1%; five minutes: 1% +Time source is NTP, 09:30:03.851 DST Wed Nov 8 2017 -VRF mgmt (VRF Id = 2); default RD 100:100; default VPNID - New CLI format, supports multiple address-families - Flags: 0x180C - Interfaces: - Et1/3 -Address family ipv4 unicast (Table ID = 0x2): - Flags: 0x0 - No Export VPN route-target communities - No Import VPN route-target communities - No import route-map - No global export route-map - No export route-map - VRF label distribution protocol: not configured - VRF label allocation mode: per-prefix -Address family ipv6 unicast not active -Address family ipv4 multicast not active +Interface IP-Address OK? Method Status Protocol +GigabitEthernet0/0/0 unassigned YES NVRAM up up +Gi0/0/0.152 192.168.241.21 YES NVRAM up up +Gi0/0/0.154 192.168.241.30 YES NVRAM up up +Gi0/0/0.600 192.168.241.141 YES NVRAM up up +Gi0/0/0.1772 120.177.177.1 YES NVRAM up up +Gi0/0/0.1774 101.177.177.1 YES NVRAM up up +Gi0/0/0.1776 100.177.177.1 YES NVRAM up up +GigabitEthernet0/0/1 unassigned YES NVRAM administratively down down +GigabitEthernet0/0/2 unassigned YES NVRAM administratively down down +GigabitEthernet0/0/3 unassigned YES NVRAM administratively down down +GigabitEthernet0/0/4 unassigned YES NVRAM administratively down down +GigabitEthernet0 192.168.243.80 YES NVRAM up up +Loopback2 192.168.242.152 YES NVRAM up up From fa32c39a7c07adc06ac391c6b334f2d2b84ce036 Mon Sep 17 00:00:00 2001 From: chonty Date: Thu, 6 Aug 2020 00:30:50 +1000 Subject: [PATCH 18/23] undo a54ceba --- napalm/ios/ios.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/napalm/ios/ios.py b/napalm/ios/ios.py index 75f0646d3..435901581 100644 --- a/napalm/ios/ios.py +++ b/napalm/ios/ios.py @@ -3395,9 +3395,6 @@ def get_network_instances(self, name=""): first_part = vrf.split("Address family")[0] - if not first_part: - return instances - # retrieve the name of the VRF and the Route Distinguisher vrf_name, RD = re.match(r"^VRF (\S+).*RD (.*);", first_part).groups() if RD == "": From b53673b91d6c7cf94887ad72958139e7b7ee64b7 Mon Sep 17 00:00:00 2001 From: chonty Date: Thu, 6 Aug 2020 00:56:00 +1000 Subject: [PATCH 19/23] reverted original test case changes properly --- .../normal/expected_result.json | 105 ++++++++++-------- .../normal/show_vrf_detail.txt | 60 +++++++--- 2 files changed, 104 insertions(+), 61 deletions(-) diff --git a/test/ios/mocked_data/test_get_network_instances/normal/expected_result.json b/test/ios/mocked_data/test_get_network_instances/normal/expected_result.json index d362f99c4..7207f5158 100644 --- a/test/ios/mocked_data/test_get_network_instances/normal/expected_result.json +++ b/test/ios/mocked_data/test_get_network_instances/normal/expected_result.json @@ -1,63 +1,78 @@ { - "Mgmt-intf":{ - "name":"Mgmt-intf", - "type":"L3VRF", - "state":{ - "route_distinguisher":"" - }, + "default":{ "interfaces":{ - "Gi0":{ + "interface":{ + "GigabitEthernet0/0/0":{ - } - } - }, - "Aut622":{ - "name":"Aut622", - "type":"L3VRF", - "state":{ - "route_distinguisher":"65421:224" - }, - "interfaces":{ - "Te2/0/0.622":{ + }, + "Gi0/0/0.152":{ - }, - "Lo622":{ + }, + "GigabitEthernet0/0/2":{ - } - } - }, - "mipepa33":{ - "name":"mipepa33", - "type":"L3VRF", - "state":{ - "route_distinguisher":"65421:942133" - }, - "interfaces":{ - "Lo199":{ + }, + "Gi0/0/0.1774":{ + + }, + "GigabitEthernet0/0/4":{ + + }, + "Gi0/0/0.1772":{ + + }, + "GigabitEthernet0/0/3":{ - }, - "Te2/0/0.1919":{ + }, + "Gi0/0/0.154":{ - }, - "Tu0":{ + }, + "GigabitEthernet0/0/1":{ - }, - "Tu4":{ + }, + "GigabitEthernet0":{ - }, - "Tu6":{ + }, + "Gi0/0/0.1776":{ + }, + "Gi0/0/0.600":{ + + }, + "Loopback2":{ + + } } - } + }, + "state":{ + "route_distinguisher":"" + }, + "type":"DEFAULT_INSTANCE", + "name":"default" }, - "vrf101":{ - "name":"vrf101", - "type":"L3VRF", + "Mgmt-intf":{ + "interfaces":{ + "interface":{ + "Gi0":{ + + } + } + }, "state":{ - "route_distinguisher":"65421:55101" + "route_distinguisher":"" }, + "type":"L3VRF", + "name":"Mgmt-intf" + }, + "opsnet":{ "interfaces":{ + "interface":{ - } + } + }, + "state":{ + "route_distinguisher":"10283:1021312690" + }, + "type":"L3VRF", + "name":"opsnet" } } diff --git a/test/ios/mocked_data/test_get_network_instances/normal/show_vrf_detail.txt b/test/ios/mocked_data/test_get_network_instances/normal/show_vrf_detail.txt index 84162f9a8..3405acdf9 100644 --- a/test/ios/mocked_data/test_get_network_instances/normal/show_vrf_detail.txt +++ b/test/ios/mocked_data/test_get_network_instances/normal/show_vrf_detail.txt @@ -1,17 +1,45 @@ -Load for five secs: 0%/0%; one minute: 1%; five minutes: 1% -Time source is NTP, 09:30:03.851 DST Wed Nov 8 2017 +Load for five secs: 0%/0%; one minute: 0%; five minutes: 1% +Time source is NTP, 09:28:50.737 DST Wed Nov 8 2017 -Interface IP-Address OK? Method Status Protocol -GigabitEthernet0/0/0 unassigned YES NVRAM up up -Gi0/0/0.152 192.168.241.21 YES NVRAM up up -Gi0/0/0.154 192.168.241.30 YES NVRAM up up -Gi0/0/0.600 192.168.241.141 YES NVRAM up up -Gi0/0/0.1772 120.177.177.1 YES NVRAM up up -Gi0/0/0.1774 101.177.177.1 YES NVRAM up up -Gi0/0/0.1776 100.177.177.1 YES NVRAM up up -GigabitEthernet0/0/1 unassigned YES NVRAM administratively down down -GigabitEthernet0/0/2 unassigned YES NVRAM administratively down down -GigabitEthernet0/0/3 unassigned YES NVRAM administratively down down -GigabitEthernet0/0/4 unassigned YES NVRAM administratively down down -GigabitEthernet0 192.168.243.80 YES NVRAM up up -Loopback2 192.168.242.152 YES NVRAM up up +VRF Mgmt-intf (VRF Id = 1); default RD ; default VPNID + New CLI format, supports multiple address-families + Flags: 0x1808 + Interfaces: + Gi0 +Address family ipv4 unicast (Table ID = 0x1): + Flags: 0x0 + No Export VPN route-target communities + No Import VPN route-target communities + No import route-map + No global export route-map + No export route-map + VRF label distribution protocol: not configured + VRF label allocation mode: per-prefix +Address family ipv6 unicast (Table ID = 0x1E000001): + Flags: 0x0 + No Export VPN route-target communities + No Import VPN route-target communities + No import route-map + No global export route-map + No export route-map + VRF label distribution protocol: not configured + VRF label allocation mode: per-prefix +Address family ipv4 multicast not active + +VRF opsnet (VRF Id = 2); default RD 10283:1021312690; default VPNID + New CLI format, supports multiple address-families + Flags: 0x180C + No interfaces +Address family ipv4 unicast (Table ID = 0x2): + Flags: 0x0 + Export VPN route-target communities + RT:10283:50000 + Import VPN route-target communities + RT:10283:50000 + No import route-map + No global export route-map + No export route-map + VRF label distribution protocol: not configured + VRF label allocation mode: per-prefix +Address family ipv6 unicast not active +Address family ipv4 multicast not active From cb09cbf3ec9ac71faf04612302d3ec58b8255379 Mon Sep 17 00:00:00 2001 From: chonty Date: Thu, 6 Aug 2020 08:43:07 +1000 Subject: [PATCH 20/23] update 'normal' test case --- .../normal/expected_result.json | 142 ++++++++---------- .../normal/show_ip_interface_brief.txt | 36 +++-- .../normal/show_vrf_detail.txt | 35 +++-- .../normal_svis/expected_result.json | 66 -------- .../normal_svis/show_ip_interface_brief.txt | 21 --- .../normal_svis/show_vrf_detail.txt | 48 ------ 6 files changed, 104 insertions(+), 244 deletions(-) delete mode 100644 test/ios/mocked_data/test_get_network_instances/normal_svis/expected_result.json delete mode 100644 test/ios/mocked_data/test_get_network_instances/normal_svis/show_ip_interface_brief.txt delete mode 100644 test/ios/mocked_data/test_get_network_instances/normal_svis/show_vrf_detail.txt diff --git a/test/ios/mocked_data/test_get_network_instances/normal/expected_result.json b/test/ios/mocked_data/test_get_network_instances/normal/expected_result.json index 7207f5158..3a0e182dd 100644 --- a/test/ios/mocked_data/test_get_network_instances/normal/expected_result.json +++ b/test/ios/mocked_data/test_get_network_instances/normal/expected_result.json @@ -1,78 +1,66 @@ { - "default":{ - "interfaces":{ - "interface":{ - "GigabitEthernet0/0/0":{ - - }, - "Gi0/0/0.152":{ - - }, - "GigabitEthernet0/0/2":{ - - }, - "Gi0/0/0.1774":{ - - }, - "GigabitEthernet0/0/4":{ - - }, - "Gi0/0/0.1772":{ - - }, - "GigabitEthernet0/0/3":{ - - }, - "Gi0/0/0.154":{ - - }, - "GigabitEthernet0/0/1":{ - - }, - "GigabitEthernet0":{ - - }, - "Gi0/0/0.1776":{ - - }, - "Gi0/0/0.600":{ - - }, - "Loopback2":{ - - } - } - }, - "state":{ - "route_distinguisher":"" - }, - "type":"DEFAULT_INSTANCE", - "name":"default" - }, - "Mgmt-intf":{ - "interfaces":{ - "interface":{ - "Gi0":{ - - } - } - }, - "state":{ - "route_distinguisher":"" - }, - "type":"L3VRF", - "name":"Mgmt-intf" - }, - "opsnet":{ - "interfaces":{ - "interface":{ - - } - }, - "state":{ - "route_distinguisher":"10283:1021312690" - }, - "type":"L3VRF", - "name":"opsnet" - } - } + "default": { + "name": "default", + "type": "DEFAULT_INSTANCE", + "state": { + "route_distinguisher": "" + }, + "interfaces": { + "interface": { + "Ethernet0/0": {}, + "Ethernet0/1": {}, + "Ethernet0/2": {}, + "Ethernet0/3": {}, + "Ethernet1/0": {}, + "Ethernet1/1": {}, + "Ethernet1/2": {}, + "Ethernet1/3": {}, + "Ethernet2/0": {}, + "Ethernet2/1": {}, + "Ethernet2/2": {}, + "Ethernet2/3": {}, + "Ethernet3/0": {}, + "Ethernet3/1": {}, + "Ethernet3/2": {}, + "Ethernet3/3": {}, + "Vlan1": {} + } + } + }, + "CustA": { + "name": "CustA", + "type": "L3VRF", + "state": { + "route_distinguisher": "1:1" + }, + "interfaces": { + "interface": { + "Vlan2": {} + } + } + }, + "CustB": { + "name": "CustB", + "type": "L3VRF", + "state": { + "route_distinguisher": "2:2" + }, + "interfaces": { + "interface": { + "Vlan3": {} + } + } + }, + "CustC": { + "name": "CustC", + "type": "L3VRF", + "state": { + "route_distinguisher": "3:3" + }, + "interfaces": { + "interface": { + "Vlan4": {} + } + } + } +} diff --git a/test/ios/mocked_data/test_get_network_instances/normal/show_ip_interface_brief.txt b/test/ios/mocked_data/test_get_network_instances/normal/show_ip_interface_brief.txt index 84162f9a8..fcee66929 100644 --- a/test/ios/mocked_data/test_get_network_instances/normal/show_ip_interface_brief.txt +++ b/test/ios/mocked_data/test_get_network_instances/normal/show_ip_interface_brief.txt @@ -1,17 +1,21 @@ -Load for five secs: 0%/0%; one minute: 1%; five minutes: 1% -Time source is NTP, 09:30:03.851 DST Wed Nov 8 2017 - Interface IP-Address OK? Method Status Protocol -GigabitEthernet0/0/0 unassigned YES NVRAM up up -Gi0/0/0.152 192.168.241.21 YES NVRAM up up -Gi0/0/0.154 192.168.241.30 YES NVRAM up up -Gi0/0/0.600 192.168.241.141 YES NVRAM up up -Gi0/0/0.1772 120.177.177.1 YES NVRAM up up -Gi0/0/0.1774 101.177.177.1 YES NVRAM up up -Gi0/0/0.1776 100.177.177.1 YES NVRAM up up -GigabitEthernet0/0/1 unassigned YES NVRAM administratively down down -GigabitEthernet0/0/2 unassigned YES NVRAM administratively down down -GigabitEthernet0/0/3 unassigned YES NVRAM administratively down down -GigabitEthernet0/0/4 unassigned YES NVRAM administratively down down -GigabitEthernet0 192.168.243.80 YES NVRAM up up -Loopback2 192.168.242.152 YES NVRAM up up +Ethernet0/0 172.29.29.220 YES manual up up +Ethernet0/1 unassigned YES unset up up +Ethernet0/2 unassigned YES unset up up +Ethernet0/3 unassigned YES unset up up +Ethernet1/0 unassigned YES unset up up +Ethernet1/1 unassigned YES unset up up +Ethernet1/2 unassigned YES unset up up +Ethernet1/3 unassigned YES unset up up +Ethernet2/0 unassigned YES unset up up +Ethernet2/1 unassigned YES unset up up +Ethernet2/2 unassigned YES unset up up +Ethernet2/3 unassigned YES unset up up +Ethernet3/0 unassigned YES unset up up +Ethernet3/1 unassigned YES unset up up +Ethernet3/2 unassigned YES unset up up +Ethernet3/3 unassigned YES unset up up +Vlan1 unassigned YES unset administratively down down +Vlan2 2.2.2.2 YES manual up up +Vlan3 3.3.3.3 YES manual up up +Vlan4 4.4.4.4 YES manual up up diff --git a/test/ios/mocked_data/test_get_network_instances/normal/show_vrf_detail.txt b/test/ios/mocked_data/test_get_network_instances/normal/show_vrf_detail.txt index 3405acdf9..e7875737b 100644 --- a/test/ios/mocked_data/test_get_network_instances/normal/show_vrf_detail.txt +++ b/test/ios/mocked_data/test_get_network_instances/normal/show_vrf_detail.txt @@ -1,11 +1,8 @@ -Load for five secs: 0%/0%; one minute: 0%; five minutes: 1% -Time source is NTP, 09:28:50.737 DST Wed Nov 8 2017 - -VRF Mgmt-intf (VRF Id = 1); default RD ; default VPNID +VRF CustA (VRF Id = 1); default RD 1:1; default VPNID New CLI format, supports multiple address-families - Flags: 0x1808 + Flags: 0x180C Interfaces: - Gi0 + Vl2 Address family ipv4 unicast (Table ID = 0x1): Flags: 0x0 No Export VPN route-target communities @@ -15,7 +12,14 @@ Address family ipv4 unicast (Table ID = 0x1): No export route-map VRF label distribution protocol: not configured VRF label allocation mode: per-prefix -Address family ipv6 unicast (Table ID = 0x1E000001): +Address family ipv6 unicast not active + +VRF CustB (VRF Id = 2); default RD 2:2; default VPNID + New CLI format, supports multiple address-families + Flags: 0x180C + Interfaces: + Vl3 +Address family ipv4 unicast (Table ID = 0x2): Flags: 0x0 No Export VPN route-target communities No Import VPN route-target communities @@ -24,22 +28,21 @@ Address family ipv6 unicast (Table ID = 0x1E000001): No export route-map VRF label distribution protocol: not configured VRF label allocation mode: per-prefix -Address family ipv4 multicast not active +Address family ipv6 unicast not active -VRF opsnet (VRF Id = 2); default RD 10283:1021312690; default VPNID +VRF CustC (VRF Id = 3); default RD 3:3; default VPNID New CLI format, supports multiple address-families Flags: 0x180C - No interfaces -Address family ipv4 unicast (Table ID = 0x2): + Interfaces: + Vl4 +Address family ipv4 unicast (Table ID = 0x3): Flags: 0x0 - Export VPN route-target communities - RT:10283:50000 - Import VPN route-target communities - RT:10283:50000 + No Export VPN route-target communities + No Import VPN route-target communities No import route-map No global export route-map No export route-map VRF label distribution protocol: not configured VRF label allocation mode: per-prefix Address family ipv6 unicast not active -Address family ipv4 multicast not active + diff --git a/test/ios/mocked_data/test_get_network_instances/normal_svis/expected_result.json b/test/ios/mocked_data/test_get_network_instances/normal_svis/expected_result.json deleted file mode 100644 index 3a0e182dd..000000000 --- a/test/ios/mocked_data/test_get_network_instances/normal_svis/expected_result.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "default": { - "name": "default", - "type": "DEFAULT_INSTANCE", - "state": { - "route_distinguisher": "" - }, - "interfaces": { - "interface": { - "Ethernet0/0": {}, - "Ethernet0/1": {}, - "Ethernet0/2": {}, - "Ethernet0/3": {}, - "Ethernet1/0": {}, - "Ethernet1/1": {}, - "Ethernet1/2": {}, - "Ethernet1/3": {}, - "Ethernet2/0": {}, - "Ethernet2/1": {}, - "Ethernet2/2": {}, - "Ethernet2/3": {}, - "Ethernet3/0": {}, - "Ethernet3/1": {}, - "Ethernet3/2": {}, - "Ethernet3/3": {}, - "Vlan1": {} - } - } - }, - "CustA": { - "name": "CustA", - "type": "L3VRF", - "state": { - "route_distinguisher": "1:1" - }, - "interfaces": { - "interface": { - "Vlan2": {} - } - } - }, - "CustB": { - "name": "CustB", - "type": "L3VRF", - "state": { - "route_distinguisher": "2:2" - }, - "interfaces": { - "interface": { - "Vlan3": {} - } - } - }, - "CustC": { - "name": "CustC", - "type": "L3VRF", - "state": { - "route_distinguisher": "3:3" - }, - "interfaces": { - "interface": { - "Vlan4": {} - } - } - } -} diff --git a/test/ios/mocked_data/test_get_network_instances/normal_svis/show_ip_interface_brief.txt b/test/ios/mocked_data/test_get_network_instances/normal_svis/show_ip_interface_brief.txt deleted file mode 100644 index fcee66929..000000000 --- a/test/ios/mocked_data/test_get_network_instances/normal_svis/show_ip_interface_brief.txt +++ /dev/null @@ -1,21 +0,0 @@ -Interface IP-Address OK? Method Status Protocol -Ethernet0/0 172.29.29.220 YES manual up up -Ethernet0/1 unassigned YES unset up up -Ethernet0/2 unassigned YES unset up up -Ethernet0/3 unassigned YES unset up up -Ethernet1/0 unassigned YES unset up up -Ethernet1/1 unassigned YES unset up up -Ethernet1/2 unassigned YES unset up up -Ethernet1/3 unassigned YES unset up up -Ethernet2/0 unassigned YES unset up up -Ethernet2/1 unassigned YES unset up up -Ethernet2/2 unassigned YES unset up up -Ethernet2/3 unassigned YES unset up up -Ethernet3/0 unassigned YES unset up up -Ethernet3/1 unassigned YES unset up up -Ethernet3/2 unassigned YES unset up up -Ethernet3/3 unassigned YES unset up up -Vlan1 unassigned YES unset administratively down down -Vlan2 2.2.2.2 YES manual up up -Vlan3 3.3.3.3 YES manual up up -Vlan4 4.4.4.4 YES manual up up diff --git a/test/ios/mocked_data/test_get_network_instances/normal_svis/show_vrf_detail.txt b/test/ios/mocked_data/test_get_network_instances/normal_svis/show_vrf_detail.txt deleted file mode 100644 index e7875737b..000000000 --- a/test/ios/mocked_data/test_get_network_instances/normal_svis/show_vrf_detail.txt +++ /dev/null @@ -1,48 +0,0 @@ -VRF CustA (VRF Id = 1); default RD 1:1; default VPNID - New CLI format, supports multiple address-families - Flags: 0x180C - Interfaces: - Vl2 -Address family ipv4 unicast (Table ID = 0x1): - Flags: 0x0 - No Export VPN route-target communities - No Import VPN route-target communities - No import route-map - No global export route-map - No export route-map - VRF label distribution protocol: not configured - VRF label allocation mode: per-prefix -Address family ipv6 unicast not active - -VRF CustB (VRF Id = 2); default RD 2:2; default VPNID - New CLI format, supports multiple address-families - Flags: 0x180C - Interfaces: - Vl3 -Address family ipv4 unicast (Table ID = 0x2): - Flags: 0x0 - No Export VPN route-target communities - No Import VPN route-target communities - No import route-map - No global export route-map - No export route-map - VRF label distribution protocol: not configured - VRF label allocation mode: per-prefix -Address family ipv6 unicast not active - -VRF CustC (VRF Id = 3); default RD 3:3; default VPNID - New CLI format, supports multiple address-families - Flags: 0x180C - Interfaces: - Vl4 -Address family ipv4 unicast (Table ID = 0x3): - Flags: 0x0 - No Export VPN route-target communities - No Import VPN route-target communities - No import route-map - No global export route-map - No export route-map - VRF label distribution protocol: not configured - VRF label allocation mode: per-prefix -Address family ipv6 unicast not active - From 1d282d5de88091bf72c9c4f7944f8aa62d723648 Mon Sep 17 00:00:00 2001 From: chonty Date: Thu, 6 Aug 2020 08:50:34 +1000 Subject: [PATCH 21/23] correct expected_result this time --- .../test_get_route_to/non_exact/expected_result.json | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/test/ios/mocked_data/test_get_route_to/non_exact/expected_result.json b/test/ios/mocked_data/test_get_route_to/non_exact/expected_result.json index b72e3ea15..d786cf6c0 100644 --- a/test/ios/mocked_data/test_get_route_to/non_exact/expected_result.json +++ b/test/ios/mocked_data/test_get_route_to/non_exact/expected_result.json @@ -3,7 +3,7 @@ { "protocol": "bgp", "outgoing_interface": "", - "age": 722, + "age": 387, "current_active": true, "routing_table": "CustA", "last_active": true, @@ -25,7 +25,7 @@ { "protocol": "bgp", "outgoing_interface": "", - "age": 722, + "age": 387, "current_active": true, "routing_table": "CustB", "last_active": true, @@ -41,13 +41,11 @@ "selected_next_hop": true, "inactive_reason": "", "preference": 0 - } - ], - "10.50.0.0/16": [ + }, { "protocol": "bgp", "outgoing_interface": "", - "age": 22, + "age": 377, "current_active": true, "routing_table": "default", "last_active": true, From 130bca911d27fe1262732a24e465f422b890013f Mon Sep 17 00:00:00 2001 From: chonty Date: Fri, 7 Aug 2020 13:28:01 +1000 Subject: [PATCH 22/23] modified test case to match test --- .../non_exact/expected_result.json | 28 ++----------------- ...50_50_0.txt => show_ip_bgp_1_0_4_0_24.txt} | 2 +- ...show_ip_bgp_vpnv4_vrf_CustA_10_50_50_0.txt | 8 ------ ...A_neighbors___include_is_169_254_255_1.txt | 1 - ...how_ip_bgp_vpnv4_vrf_CustB_1_0_4_0_24.txt} | 2 +- ...> show_ip_route_1_0_4_0_255_255_255_0.txt} | 2 +- .../show_ip_route_vrf_CustA_10_50_50_0.txt | 10 ------- ..._route_vrf_CustA_1_0_4_0_255_255_255_0.txt | 1 + ...route_vrf_CustB_1_0_4_0_255_255_255_0.txt} | 2 +- 9 files changed, 8 insertions(+), 48 deletions(-) rename test/ios/mocked_data/test_get_route_to/non_exact/{show_ip_bgp_10_50_50_0.txt => show_ip_bgp_1_0_4_0_24.txt} (82%) delete mode 100644 test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustA_10_50_50_0.txt delete mode 100644 test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustA_neighbors___include_is_169_254_255_1.txt rename test/ios/mocked_data/test_get_route_to/non_exact/{show_ip_bgp_vpnv4_vrf_CustB_10_50_50_0.txt => show_ip_bgp_vpnv4_vrf_CustB_1_0_4_0_24.txt} (82%) rename test/ios/mocked_data/test_get_route_to/non_exact/{show_ip_route_10_50_50_0.txt => show_ip_route_1_0_4_0_255_255_255_0.txt} (90%) delete mode 100644 test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_vrf_CustA_10_50_50_0.txt create mode 100644 test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_vrf_CustA_1_0_4_0_255_255_255_0.txt rename test/ios/mocked_data/test_get_route_to/non_exact/{show_ip_route_vrf_CustB_10_50_50_0.txt => show_ip_route_vrf_CustB_1_0_4_0_255_255_255_0.txt} (90%) diff --git a/test/ios/mocked_data/test_get_route_to/non_exact/expected_result.json b/test/ios/mocked_data/test_get_route_to/non_exact/expected_result.json index d786cf6c0..ea0b9b259 100644 --- a/test/ios/mocked_data/test_get_route_to/non_exact/expected_result.json +++ b/test/ios/mocked_data/test_get_route_to/non_exact/expected_result.json @@ -1,31 +1,9 @@ { - "10.50.50.0/23": [ + "1.0.4.0/24": [ { "protocol": "bgp", "outgoing_interface": "", - "age": 387, - "current_active": true, - "routing_table": "CustA", - "last_active": true, - "protocol_attributes": { - "as_path": "Local", - "remote_address": "169.254.255.1", - "communities": [], - "local_preference": 100, - "local_as": 1, - "remote_as": 1 - }, - "next_hop": "169.254.255.1", - "selected_next_hop": true, - "inactive_reason": "", - "preference": 0 - } - ], - "10.50.50.0/24": [ - { - "protocol": "bgp", - "outgoing_interface": "", - "age": 387, + "age": 98, "current_active": true, "routing_table": "CustB", "last_active": true, @@ -45,7 +23,7 @@ { "protocol": "bgp", "outgoing_interface": "", - "age": 377, + "age": 62, "current_active": true, "routing_table": "default", "last_active": true, diff --git a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_10_50_50_0.txt b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_1_0_4_0_24.txt similarity index 82% rename from test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_10_50_50_0.txt rename to test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_1_0_4_0_24.txt index 62a724467..6a4fe2cc7 100644 --- a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_10_50_50_0.txt +++ b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_1_0_4_0_24.txt @@ -1,4 +1,4 @@ -BGP routing table entry for 10.50.50.0/24, version 2 +BGP routing table entry for 1.0.4.0/24, version 2 Paths: (1 available, best #1, table default) Advertised to update-groups: 2 diff --git a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustA_10_50_50_0.txt b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustA_10_50_50_0.txt deleted file mode 100644 index e7ea0cfde..000000000 --- a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustA_10_50_50_0.txt +++ /dev/null @@ -1,8 +0,0 @@ -BGP routing table entry for 2:2:10.50.50.0/23, version 2 -Paths: (1 available, best #1, table CustA) - Not advertised to any peer - Refresh Epoch 1 - Local - 169.254.255.1 (via vrf CustA) from 169.254.255.1 (1.1.1.1) - Origin IGP, metric 0, localpref 100, valid, internal, best - rx pathid: 0, tx pathid: 0x0 diff --git a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustA_neighbors___include_is_169_254_255_1.txt b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustA_neighbors___include_is_169_254_255_1.txt deleted file mode 100644 index ab594d932..000000000 --- a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustA_neighbors___include_is_169_254_255_1.txt +++ /dev/null @@ -1 +0,0 @@ -BGP neighbor is 169.254.255.1, vrf CustA, remote AS 1, internal link diff --git a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustB_10_50_50_0.txt b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustB_1_0_4_0_24.txt similarity index 82% rename from test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustB_10_50_50_0.txt rename to test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustB_1_0_4_0_24.txt index 114de91ec..31895d6a4 100644 --- a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustB_10_50_50_0.txt +++ b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_bgp_vpnv4_vrf_CustB_1_0_4_0_24.txt @@ -1,4 +1,4 @@ -BGP routing table entry for 3:3:10.50.50.0/24, version 3 +BGP routing table entry for 3:3:1.0.4.0/24, version 3 Paths: (1 available, best #1, table CustB) Not advertised to any peer Refresh Epoch 1 diff --git a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_10_50_50_0.txt b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_1_0_4_0_255_255_255_0.txt similarity index 90% rename from test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_10_50_50_0.txt rename to test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_1_0_4_0_255_255_255_0.txt index 415ec83a1..5f43ba8d9 100644 --- a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_10_50_50_0.txt +++ b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_1_0_4_0_255_255_255_0.txt @@ -1,4 +1,4 @@ -Routing entry for 10.50.50.0/24 +Routing entry for 1.0.4.0/24 Known via "bgp 1", distance 20, metric 0 Tag 3, type external Last update from 200.200.200.1 00:01:02 ago diff --git a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_vrf_CustA_10_50_50_0.txt b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_vrf_CustA_10_50_50_0.txt deleted file mode 100644 index 368d82f56..000000000 --- a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_vrf_CustA_10_50_50_0.txt +++ /dev/null @@ -1,10 +0,0 @@ - -Routing Table: CustA -Routing entry for 10.50.50.0/23 - Known via "bgp 1", distance 200, metric 0, type internal - Last update from 169.254.255.1 00:01:48 ago - Routing Descriptor Blocks: - * 169.254.255.1, from 169.254.255.1, 00:01:48 ago - Route metric is 0, traffic share count is 1 - AS Hops 0 - MPLS label: none diff --git a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_vrf_CustA_1_0_4_0_255_255_255_0.txt b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_vrf_CustA_1_0_4_0_255_255_255_0.txt new file mode 100644 index 000000000..3c5449984 --- /dev/null +++ b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_vrf_CustA_1_0_4_0_255_255_255_0.txt @@ -0,0 +1 @@ +% Network not in table diff --git a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_vrf_CustB_10_50_50_0.txt b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_vrf_CustB_1_0_4_0_255_255_255_0.txt similarity index 90% rename from test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_vrf_CustB_10_50_50_0.txt rename to test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_vrf_CustB_1_0_4_0_255_255_255_0.txt index 1cedd6a15..c3c8dba2e 100644 --- a/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_vrf_CustB_10_50_50_0.txt +++ b/test/ios/mocked_data/test_get_route_to/non_exact/show_ip_route_vrf_CustB_1_0_4_0_255_255_255_0.txt @@ -1,6 +1,6 @@ Routing Table: CustB -Routing entry for 10.50.50.0/24 +Routing entry for 1.0.4.0/24 Known via "bgp 1", distance 200, metric 0, type internal Last update from 169.254.255.1 00:01:38 ago Routing Descriptor Blocks: From 168d8a9e33c5265bfaa6c86153b9527d3da67e14 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 7 Aug 2020 06:33:01 +0000 Subject: [PATCH 23/23] Bump tox from 3.18.1 to 3.19.0 Bumps [tox](https://github.com/tox-dev/tox) from 3.18.1 to 3.19.0. - [Release notes](https://github.com/tox-dev/tox/releases) - [Changelog](https://github.com/tox-dev/tox/blob/master/docs/changelog.rst) - [Commits](https://github.com/tox-dev/tox/compare/3.18.1...3.19.0) Signed-off-by: dependabot-preview[bot] --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 062fc22e3..1457bb8f8 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -8,4 +8,4 @@ pytest-json==0.4.0 pytest-pythonpath==0.7.3 pylama==7.7.1 mock==4.0.2 -tox==3.18.1 \ No newline at end of file +tox==3.19.0 \ No newline at end of file