From ece9a358a8f8ef6675a689776a5c1e2a5952f8b8 Mon Sep 17 00:00:00 2001 From: Mabuchin Date: Fri, 12 Apr 2019 19:15:49 +0900 Subject: [PATCH] Fix broken get_bgp_neighbors when 6PE configured on eos (#945) * fix _RE_BGP_PREFIX and NEIGHBOR_FILTER for 6PE into eos * add testcase for 6PE version * Renamed testcase mocked file for regexp syntax change --- napalm/eos/eos.py | 4 +- ...E_____0_9____Local_AS_Desc_BGP_state.text} | 0 ...E_____0_9____Local_AS_Desc_BGP_state.text} | 0 .../issue944/expected_result.json | 91 +++++++++++++++++++ ...PE_____0_9____Local_AS_Desc_BGP_state.text | 12 +++ .../issue944/show_ip_bgp_summary_vrf_all.json | 37 ++++++++ ...E_____0_9____Local_AS_Desc_BGP_state.text} | 0 .../show_ipv6_bgp_summary_vrf_all.json | 37 ++++++++ ...E_____0_9____Local_AS_Desc_BGP_state.text} | 0 ...PE_____0_9____Local_AS_Desc_BGP_state.text | 12 +++ 10 files changed, 191 insertions(+), 2 deletions(-) rename test/eos/mocked_data/test_get_bgp_neighbors/issue58_neighbor_down/{show_ip_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46__Unicast____0_9____Local_AS_Desc_BGP_state.text => show_ip_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46___Unicast_6PE_____0_9____Local_AS_Desc_BGP_state.text} (100%) rename test/eos/mocked_data/test_get_bgp_neighbors/issue58_neighbor_down/{show_ipv6_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46__Unicast____0_9____Local_AS_Desc_BGP_state.text => show_ipv6_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46___Unicast_6PE_____0_9____Local_AS_Desc_BGP_state.text} (100%) create mode 100644 test/eos/mocked_data/test_get_bgp_neighbors/issue944/expected_result.json create mode 100644 test/eos/mocked_data/test_get_bgp_neighbors/issue944/show_ip_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46___Unicast_6PE_____0_9____Local_AS_Desc_BGP_state.text create mode 100644 test/eos/mocked_data/test_get_bgp_neighbors/issue944/show_ip_bgp_summary_vrf_all.json rename test/eos/mocked_data/test_get_bgp_neighbors/{normal/show_ipv6_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46__Unicast____0_9____Local_AS_Desc_BGP_state.text => issue944/show_ipv6_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46___Unicast_6PE_____0_9____Local_AS_Desc_BGP_state.text} (100%) create mode 100644 test/eos/mocked_data/test_get_bgp_neighbors/issue944/show_ipv6_bgp_summary_vrf_all.json rename test/eos/mocked_data/test_get_bgp_neighbors/normal/{show_ip_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46__Unicast____0_9____Local_AS_Desc_BGP_state.text => show_ip_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46___Unicast_6PE_____0_9____Local_AS_Desc_BGP_state.text} (100%) create mode 100644 test/eos/mocked_data/test_get_bgp_neighbors/normal/show_ipv6_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46___Unicast_6PE_____0_9____Local_AS_Desc_BGP_state.text diff --git a/napalm/eos/eos.py b/napalm/eos/eos.py index 578030b00..5d73bfd46 100644 --- a/napalm/eos/eos.py +++ b/napalm/eos/eos.py @@ -76,7 +76,7 @@ class EOSDriver(NetworkDriver): _RE_BGP_DESC = re.compile(r"\s+Description: (?P.*?)$") _RE_BGP_LOCAL = re.compile(r"Local AS is (?P.*?),.*") _RE_BGP_PREFIX = re.compile( - r"(\s*?)(?PIPv[46]) Unicast:\s*(?P\d+)\s*(?P\d+)" + r"(\s*?)(?PIPv[46]) (Unicast|6PE):\s*(?P\d+)\s*(?P\d+)" ) # noqa _RE_SNMP_COMM = re.compile( r"""^snmp-server\s+community\s+(?P\S+) @@ -426,7 +426,7 @@ def get_re_group(res, key, default=None): except KeyError: return default - NEIGHBOR_FILTER = "bgp neighbors vrf all | include remote AS | remote router ID |IPv[46] Unicast:.*[0-9]+|^Local AS|Desc|BGP state" # noqa + NEIGHBOR_FILTER = "bgp neighbors vrf all | include remote AS | remote router ID |IPv[46] (Unicast|6PE):.*[0-9]+|^Local AS|Desc|BGP state" # noqa output_summary_cmds = self.device.run_commands( ["show ipv6 bgp summary vrf all", "show ip bgp summary vrf all"], encoding="json", diff --git a/test/eos/mocked_data/test_get_bgp_neighbors/issue58_neighbor_down/show_ip_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46__Unicast____0_9____Local_AS_Desc_BGP_state.text b/test/eos/mocked_data/test_get_bgp_neighbors/issue58_neighbor_down/show_ip_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46___Unicast_6PE_____0_9____Local_AS_Desc_BGP_state.text similarity index 100% rename from test/eos/mocked_data/test_get_bgp_neighbors/issue58_neighbor_down/show_ip_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46__Unicast____0_9____Local_AS_Desc_BGP_state.text rename to test/eos/mocked_data/test_get_bgp_neighbors/issue58_neighbor_down/show_ip_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46___Unicast_6PE_____0_9____Local_AS_Desc_BGP_state.text diff --git a/test/eos/mocked_data/test_get_bgp_neighbors/issue58_neighbor_down/show_ipv6_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46__Unicast____0_9____Local_AS_Desc_BGP_state.text b/test/eos/mocked_data/test_get_bgp_neighbors/issue58_neighbor_down/show_ipv6_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46___Unicast_6PE_____0_9____Local_AS_Desc_BGP_state.text similarity index 100% rename from test/eos/mocked_data/test_get_bgp_neighbors/issue58_neighbor_down/show_ipv6_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46__Unicast____0_9____Local_AS_Desc_BGP_state.text rename to test/eos/mocked_data/test_get_bgp_neighbors/issue58_neighbor_down/show_ipv6_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46___Unicast_6PE_____0_9____Local_AS_Desc_BGP_state.text diff --git a/test/eos/mocked_data/test_get_bgp_neighbors/issue944/expected_result.json b/test/eos/mocked_data/test_get_bgp_neighbors/issue944/expected_result.json new file mode 100644 index 000000000..a22cd863f --- /dev/null +++ b/test/eos/mocked_data/test_get_bgp_neighbors/issue944/expected_result.json @@ -0,0 +1,91 @@ +{ + "global": { + "router_id": "192.168.56.3", + "peers": { + "192.168.56.4": { + "is_enabled": true, + "uptime": "...", + "remote_as": 65001, + "description": "", + "remote_id": "192.168.56.3", + "local_as": 65002, + "is_up": false, + "address_family": { + "ipv4": { + "sent_prefixes": 0, + "accepted_prefixes": -1, + "received_prefixes": 0 + }, + "ipv6": { + "sent_prefixes": 0, + "accepted_prefixes": -1, + "received_prefixes": 0 + } + } + }, + "192.168.56.2": { + "is_enabled": true, + "uptime": "...", + "remote_as": 65002, + "description": "", + "remote_id": "192.168.56.2", + "local_as": 65001, + "is_up": true, + "address_family": { + "ipv4": { + "sent_prefixes": 0, + "accepted_prefixes": -1, + "received_prefixes": 0 + }, + "ipv6": { + "sent_prefixes": 0, + "accepted_prefixes": -1, + "received_prefixes": 0 + } + } + }, + "2001:7f8::f10:0:2": { + "is_enabled": true, + "uptime": "...", + "remote_as": 65002, + "description": "", + "remote_id": "192.168.56.2", + "local_as": 65001, + "is_up": true, + "address_family": { + "ipv4": { + "sent_prefixes": 0, + "accepted_prefixes": -1, + "received_prefixes": 0 + }, + "ipv6": { + "sent_prefixes": 0, + "accepted_prefixes": -1, + "received_prefixes": 0 + } + } + }, + "2001:7f8::f10:0:3": { + "is_enabled": true, + "uptime": "...", + "remote_as": 65001, + "description": "", + "remote_id": "192.168.56.3", + "local_as": 65002, + "is_up": false, + "address_family": { + "ipv4": { + "sent_prefixes": 0, + "accepted_prefixes": -1, + "received_prefixes": 0 + }, + "ipv6": { + "sent_prefixes": 0, + "accepted_prefixes": -1, + "received_prefixes": 0 + } + } + } + } + } +} diff --git a/test/eos/mocked_data/test_get_bgp_neighbors/issue944/show_ip_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46___Unicast_6PE_____0_9____Local_AS_Desc_BGP_state.text b/test/eos/mocked_data/test_get_bgp_neighbors/issue944/show_ip_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46___Unicast_6PE_____0_9____Local_AS_Desc_BGP_state.text new file mode 100644 index 000000000..577f118a3 --- /dev/null +++ b/test/eos/mocked_data/test_get_bgp_neighbors/issue944/show_ip_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46___Unicast_6PE_____0_9____Local_AS_Desc_BGP_state.text @@ -0,0 +1,12 @@ +BGP neighbor is 192.168.56.2, remote AS 65002, external link + BGP version 4, remote router ID 192.168.56.2, VRF default + BGP state is Established, up for 32d16h + IPv4 Unicast: 0 0 + IPv6 6PE: 0 0 +Local AS is 65001, local router ID 192.168.56.3 +BGP neighbor is 192.168.56.4, remote AS 65001, external link + BGP version 4, remote router ID 192.168.56.3, VRF default + BGP state is Established, up for 32d16h + IPv4 Unicast: 0 0 + IPv6 6PE: 0 0 +Local AS is 65002, local router ID 192.168.56.2 diff --git a/test/eos/mocked_data/test_get_bgp_neighbors/issue944/show_ip_bgp_summary_vrf_all.json b/test/eos/mocked_data/test_get_bgp_neighbors/issue944/show_ip_bgp_summary_vrf_all.json new file mode 100644 index 000000000..850feca5e --- /dev/null +++ b/test/eos/mocked_data/test_get_bgp_neighbors/issue944/show_ip_bgp_summary_vrf_all.json @@ -0,0 +1,37 @@ +{ +"vrfs": { +"default": { +"routerId": "192.168.56.3", +"peers": { +"192.168.56.2": { +"msgSent": 6, +"inMsgQueue": 0, +"prefixReceived": 0, +"upDownTime": 1452680643.198489, +"version": 4, +"msgReceived": 5, +"prefixAccepted": 0, +"peerState": "Established", +"outMsgQueue": 0, +"underMaintenance": false, +"asn": 65002 +}, +"192.168.56.4": { +"msgSent": 267, +"inMsgQueue": 0, +"prefixReceived": 0, +"upDownTime": 1452696202.499104, +"version": 4, +"msgReceived": 263, +"prefixAccepted": 0, +"peerState": "Active", +"outMsgQueue": 0, +"underMaintenance": false, +"asn": 65001 +} +}, +"vrf": "default", +"asn": 65001 +} +} +} diff --git a/test/eos/mocked_data/test_get_bgp_neighbors/normal/show_ipv6_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46__Unicast____0_9____Local_AS_Desc_BGP_state.text b/test/eos/mocked_data/test_get_bgp_neighbors/issue944/show_ipv6_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46___Unicast_6PE_____0_9____Local_AS_Desc_BGP_state.text similarity index 100% rename from test/eos/mocked_data/test_get_bgp_neighbors/normal/show_ipv6_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46__Unicast____0_9____Local_AS_Desc_BGP_state.text rename to test/eos/mocked_data/test_get_bgp_neighbors/issue944/show_ipv6_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46___Unicast_6PE_____0_9____Local_AS_Desc_BGP_state.text diff --git a/test/eos/mocked_data/test_get_bgp_neighbors/issue944/show_ipv6_bgp_summary_vrf_all.json b/test/eos/mocked_data/test_get_bgp_neighbors/issue944/show_ipv6_bgp_summary_vrf_all.json new file mode 100644 index 000000000..a68112c2b --- /dev/null +++ b/test/eos/mocked_data/test_get_bgp_neighbors/issue944/show_ipv6_bgp_summary_vrf_all.json @@ -0,0 +1,37 @@ +{ +"vrfs": { +"default": { +"routerId": "192.168.56.3", +"peers": { +"2001:7f8::f10:0:2": { +"msgSent": 5, +"inMsgQueue": 0, +"prefixReceived": 0, +"upDownTime": 1452681618.167685, +"version": 4, +"msgReceived": 5, +"prefixAccepted": 0, +"peerState": "Established", +"outMsgQueue": 0, +"underMaintenance": false, +"asn": 65002 +}, +"2001:7f8::f10:0:3": { +"msgSent": 267, +"inMsgQueue": 0, +"prefixReceived": 0, +"upDownTime": 1452696202.499104, +"version": 4, +"msgReceived": 263, +"prefixAccepted": 0, +"peerState": "Active", +"outMsgQueue": 0, +"underMaintenance": false, +"asn": 65001 +} +}, +"vrf": "default", +"asn": 65001 +} +} +} diff --git a/test/eos/mocked_data/test_get_bgp_neighbors/normal/show_ip_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46__Unicast____0_9____Local_AS_Desc_BGP_state.text b/test/eos/mocked_data/test_get_bgp_neighbors/normal/show_ip_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46___Unicast_6PE_____0_9____Local_AS_Desc_BGP_state.text similarity index 100% rename from test/eos/mocked_data/test_get_bgp_neighbors/normal/show_ip_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46__Unicast____0_9____Local_AS_Desc_BGP_state.text rename to test/eos/mocked_data/test_get_bgp_neighbors/normal/show_ip_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46___Unicast_6PE_____0_9____Local_AS_Desc_BGP_state.text diff --git a/test/eos/mocked_data/test_get_bgp_neighbors/normal/show_ipv6_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46___Unicast_6PE_____0_9____Local_AS_Desc_BGP_state.text b/test/eos/mocked_data/test_get_bgp_neighbors/normal/show_ipv6_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46___Unicast_6PE_____0_9____Local_AS_Desc_BGP_state.text new file mode 100644 index 000000000..6643bdc03 --- /dev/null +++ b/test/eos/mocked_data/test_get_bgp_neighbors/normal/show_ipv6_bgp_neighbors_vrf_all___include_remote_AS___remote_router_ID__IPv_46___Unicast_6PE_____0_9____Local_AS_Desc_BGP_state.text @@ -0,0 +1,12 @@ +BGP neighbor is 2001:7f8::f10:0:2, remote AS 65002, external link + BGP version 4, remote router ID 192.168.56.2, VRF default + BGP state is Established, up for 32d16h + IPv4 Unicast: 0 0 + IPv6 Unicast: 0 0 +Local AS is 65001, local router ID 192.168.56.3 +BGP neighbor is 2001:7f8::f10:0:3, remote AS 65001, external link + BGP version 4, remote router ID 192.168.56.3, VRF default + BGP state is Established, up for 32d16h + IPv4 Unicast: 0 0 + IPv6 Unicast: 0 0 +Local AS is 65002, local router ID 192.168.56.2