From 07a18de7f263314dbef739653510710638063048 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Fri, 19 Apr 2024 19:37:29 +0100 Subject: [PATCH 01/39] Create test --- .../verify/verify_eigrp_interfaces_timers/mock_data/iosxe/test | 1 + 1 file changed, 1 insertion(+) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/test diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/test b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/test new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/test @@ -0,0 +1 @@ + From ea82622390c3415ffa3e2a9d599775bea9c5d502 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Fri, 19 Apr 2024 19:38:35 +0100 Subject: [PATCH 02/39] Add files via upload add mock for verify_eigrp_interfaces_timers --- .../mock_data/iosxe/mock_data.yaml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml new file mode 100644 index 000000000..5f7244bd1 --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml @@ -0,0 +1,57 @@ +configure: + commands: + end: + new_state: execute + line console 0: + new_state: configure_line + no logging console: '' + prompt: R1(config)# +configure_line: + commands: + end: + new_state: execute + exec-timeout 0: '' + prompt: R1(config-line)# +connect: + commands: + ? '' + : new_state: execute + preface: 'Trying mock_device ... + + Connected to mock_device. + + Escape character is ''^]''.' + prompt: '' +execute: + commands: + config term: + new_state: configure + config-transaction: + new_state: configure + show ip eigrp interfaces detail: + response: + - "EIGRP-IPv4 Interfaces for AS(1)\r\n Xmit Queue\ + \ PeerQ Mean Pacing Time Multicast Pending\r\nInterface \ + \ Peers Un/Reliable Un/Reliable SRTT Un/Reliable Flow Timer\ + \ Routes\r\nFa0/0 1 0/0 0/0 32\ + \ 0/0 50 0\r\n Hello-interval is 5, Hold-time is\ + \ 15\r\n Split-horizon is enabled\r\n Next xmit serial \r\n Packetized\ + \ sent/expedited: 1/0\r\n Hello's sent/expedited: 303/2\r\n Un/reliable\ + \ mcasts: 0/1 Un/reliable ucasts: 1/2\r\n Mcast exceptions: 0 CR packets:\ + \ 0 ACKs suppressed: 0\r\n Retransmissions sent: 1 Out-of-sequence rcvd:\ + \ 1\r\n Topology-ids on interface - 0 \r\n Authentication mode is not set\r\ + \nEIGRP-IPv4 Interfaces for AS(2)\r\n Xmit Queue\ + \ PeerQ Mean Pacing Time Multicast Pending\r\nInterface \ + \ Peers Un/Reliable Un/Reliable SRTT Un/Reliable Flow Timer\ + \ Routes\r\nFa1/0 0 0/0 0/0 0\ + \ 0/0 0 0\r\n Hello-interval is 5, Hold-time is\ + \ 15\r\n Split-horizon is enabled\r\n Next xmit serial \r\n Packetized\ + \ sent/expedited: 0/0\r\n Hello's sent/expedited: 304/1\r\n Un/reliable\ + \ mcasts: 0/0 Un/reliable ucasts: 0/0\r\n Mcast exceptions: 0 CR packets:\ + \ 0 ACKs suppressed: 0\r\n Retransmissions sent: 0 Out-of-sequence rcvd:\ + \ 0\r\n Topology-ids on interface - 0 \r\n Authentication mode is not set" + response_type: circular + show version: '' + term length 0: '' + term width 0: '' + prompt: R1# From 71e6b746639e1f8ff183255702c4da1e214606e5 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Fri, 19 Apr 2024 19:39:30 +0100 Subject: [PATCH 03/39] Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/test --- .../verify/verify_eigrp_interfaces_timers/mock_data/iosxe/test | 1 - 1 file changed, 1 deletion(-) delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/test diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/test b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/test deleted file mode 100644 index 8b1378917..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/test +++ /dev/null @@ -1 +0,0 @@ - From 3d8629bb2040a5bdc07579e618b8f472aea584ab Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Fri, 19 Apr 2024 19:40:22 +0100 Subject: [PATCH 04/39] Add files via upload Add test_api_verify_eigrp_interfaces_timers.py --- ...test_api_verify_eigrp_interfaces_timers.py | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/test_api_verify_eigrp_interfaces_timers.py diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/test_api_verify_eigrp_interfaces_timers.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/test_api_verify_eigrp_interfaces_timers.py new file mode 100644 index 000000000..1c45eb39b --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/test_api_verify_eigrp_interfaces_timers.py @@ -0,0 +1,35 @@ +import os +import unittest +from pyats.topology import loader +from genie.libs.sdk.apis.iosxe.eigrp.verify import verify_eigrp_interfaces_timers + + +class TestVerifyEigrpInterfacesTimers(unittest.TestCase): + + @classmethod + def setUpClass(self): + testbed = f""" + devices: + R1: + connections: + defaults: + class: unicon.Unicon + a: + command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect + protocol: unknown + os: iosxe + platform: iosxe + type: iosxe + """ + self.testbed = loader.load(testbed) + self.device = self.testbed.devices['R1'] + self.device.connect( + learn_hostname=True, + init_config_commands=[], + init_exec_commands=[] + ) + + def test_verify_eigrp_interfaces_timers(self): + result = verify_eigrp_interfaces_timers(self.device, {'FastEthernet0/0': [{'hello_interval': 5}, {'hold_time': 15}]}, 'default', 1, 'ipv4', 60, 10) + expected_output = True + self.assertEqual(result, expected_output) From ad2867781fe2a23e96edc81c8542fa393b48aaa2 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Fri, 19 Apr 2024 19:45:06 +0100 Subject: [PATCH 05/39] Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py --- .../genie/libs/sdk/apis/iosxe/eigrp/verify.py | 180 ------------------ 1 file changed, 180 deletions(-) delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py deleted file mode 100644 index 9191b5b46..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py +++ /dev/null @@ -1,180 +0,0 @@ -from genie.utils.timeout import Timeout -import logging -import os -from genie.metaparser.util.exceptions import SchemaEmptyParserError - -log = logging.getLogger(__name__) - - -def verify_eigrp_interfaces( - device, - vrf="default", - AS_N=None, - interfaces_list=None, - ip="ipv4", - max_time=60, - check_interval=10, -): - """Verify active EIGRP interfaces for ipv4 (Default) or ipv6 for AS and VRF - Args: - device (obj): Device object - vrf = "default" (str): Name of the vrf by default set to "default" - AS_N = None (int): Autonomous System - interfaces_list = None (list): List of active EIGRP interfaces to check - ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" - max_time (`int`): Max time, default: 30 - check_interval (`int`): Check interval, default: 10 - - Returns: - True - False - """ - assert isinstance(AS_N, int), "AS_N must be int" - assert isinstance(vrf, str), "vrf must be str" - assert isinstance( - interfaces_list, list - ), "interfaces_list must be list of interfaces" - assert AS_N != 0, "AS_N must not be 0" - assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" - timeout = Timeout(max_time, check_interval) - while timeout.iterate(): - if AS_N and interfaces_list: - try: - response = device.parse( - f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp interfaces" - ) - except SchemaEmptyParserError: - timeout.sleep() - continue - interfaces = [] - if (vrf not in response.q.get_values("vrf")) or ( - str(AS_N) not in response.q.get_values("eigrp_instance") - ): - log.error( - f"Sorry,no data for the provided 'AS = {AS_N}' and/or 'vrf = {vrf}' !" - ) - else: - interfaces = ( - response.q.contains(vrf) - .contains_key_value("eigrp_instance", str(AS_N)) - .contains(ip) - .get_values("interface") - ) - return set(interfaces_list).issubset(interfaces) - log.error( - f"Please, provide a valid format for AS, interfaces_list, ip and/or vrf" - ) - continue - - -def verify_eigrp_neighbors( - device, - neighbors=None, - vrf="default", - AS_N=None, - ip="ipv4", - max_time=60, - check_interval=10, -): - """Verify active EIGRP neighbors for ipv4 (Default) and ipv6 for AS and VRF - Args: - device (obj): Device object - neighbors = None (list): Active EIGRP neighbors to check - vrf = "default" (str) : Name of the vrf - AS_N = None (int) : Autonomous System - ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" - max_time (`int`): Max time, default: 30 - check_interval (`int`): Check interval, default: 10 - - Returns: - True - False - """ - assert isinstance(AS_N, int), "AS_N must be int" - assert isinstance(vrf, str), "vrf must be str" - assert isinstance(neighbors, list), "neighbors must be list of interfaces" - assert AS_N != 0, "AS_N must not be 0" - assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" - timeout = Timeout(max_time, check_interval) - while timeout.iterate(): - if AS_N and neighbors: - try: - response = device.parse( - f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp neighbors" - ) - except SchemaEmptyParserError: - timeout.sleep() - continue - eigrp_neighbors = [] - if (vrf not in response.q.get_values("vrf")) or ( - str(AS_N) not in response.q.get_values("eigrp_instance") - ): - log.error( - f"Sorry, no data for the provided 'AS = {AS_N}' and/or 'vrf = {vrf}' !" - ) - else: - eigrp_neighbors = ( - response.q.contains_key_value("eigrp_instance", str(AS_N)) - .contains(vrf) - .contains(ip) - .get_values("eigrp_nbr") - ) - return set(neighbors).issubset(eigrp_neighbors) - log.error(f"Please, provide a valid format for AS, Neighbors, ip and/or vrf") - continue - -def verify_eigrp_router_id( - device, - router_id=None, - vrf="default", - auto_sys=None, - ip="ipv4", - max_time=60, - check_interval=10, -): - """verify EIGRP IDs for a given vrf and auto_sys active instance for ipv4 or ipv6 - Args: - device (obj): Device object - router_id = None (list): List of router ID to check - vrf = "default" (str): Name of the vrf by default set to "default" - auto_sys = None (int) : Autonomous System - ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" - max_time (`int`): Max time, default: 30 - check_interval (`int`): Check interval, default: 10 - - Returns: - True - False - """ - assert isinstance(auto_sys, int), "auto_sys must be int" - assert isinstance(vrf, str), "vrf must be str" - assert isinstance(router_id, list), "router_id must be list of router IDs" - assert auto_sys != 0, "auto_sys must not be 0" - assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" - timeout = Timeout(max_time, check_interval) - while timeout.iterate(): - if auto_sys and router_id: - try: - response = device.parse( - f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp topology" - ) - except SchemaEmptyParserError: - timeout.sleep() - continue - eigrp_id = [] - if (vrf not in response.q.get_values("vrf")) or ( - str(auto_sys) not in response.q.get_values("eigrp_instance") - ): - log.error( - f"Sorry, no data for the provided for 'auto_sys = {auto_sys}' and/or 'vrf = {vrf}'" - ) - else: - eigrp_id = ( - response.q.contains_key_value("eigrp_instance", str(auto_sys)) - .contains(vrf) - .contains((ip[0:2]).upper() + ip[2:]) - .get_values("eigrp_id") - ) - return set(router_id).issubset(eigrp_id) - log.error(f"Please, provid a valid format for auto_sys, router_id, vrf and/or ip") - continue From 0c3f6175336bbd6d3830cebdbd6f19790d97e4ef Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Fri, 19 Apr 2024 19:46:34 +0100 Subject: [PATCH 06/39] Add files via upload Add verify_eigrp_interfaces_timers APIs for IOSXE/IOS EIGRP verify supporting ipv4 and ipv6 to my previous contribution verify.py --- .../genie/libs/sdk/apis/iosxe/eigrp/verify.py | 251 ++++++++++++++++++ 1 file changed, 251 insertions(+) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py new file mode 100644 index 000000000..427e44a1a --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py @@ -0,0 +1,251 @@ +from genie.utils.timeout import Timeout +import logging +import os +from genie.metaparser.util.exceptions import SchemaEmptyParserError + +log = logging.getLogger(__name__) + + +def verify_eigrp_interfaces( + device, + vrf="default", + AS_N=None, + interfaces_list=None, + ip="ipv4", + max_time=60, + check_interval=10, +): + """Verify active EIGRP interfaces for ipv4 (Default) or ipv6 for AS and VRF + Args: + device (obj): Device object + vrf = "default" (str): Name of the vrf by default set to "default" + AS_N = None (int): Autonomous System + interfaces_list = None (list): List of active EIGRP interfaces to check + ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" + max_time (`int`): Max time, default: 30 + check_interval (`int`): Check interval, default: 10 + + Returns: + True + False + """ + assert isinstance(AS_N, int), "AS_N must be int" + assert isinstance(vrf, str), "vrf must be str" + assert isinstance( + interfaces_list, list + ), "interfaces_list must be list of interfaces" + assert AS_N != 0, "AS_N must not be 0" + assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" + timeout = Timeout(max_time, check_interval) + while timeout.iterate(): + if AS_N and interfaces_list: + try: + response = device.parse( + f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp interfaces" + ) + except SchemaEmptyParserError: + timeout.sleep() + continue + interfaces = [] + if (vrf not in response.q.get_values("vrf")) or ( + str(AS_N) not in response.q.get_values("eigrp_instance") + ): + log.error( + f"Sorry,no data for the provided 'AS = {AS_N}' and/or 'vrf = {vrf}' !" + ) + else: + interfaces = ( + response.q.contains(vrf) + .contains_key_value("eigrp_instance", str(AS_N)) + .contains(ip) + .get_values("interface") + ) + return set(interfaces_list).issubset(interfaces) + log.error( + f"Please, provide a valid format for AS, interfaces_list, ip and/or vrf" + ) + continue + + +def verify_eigrp_neighbors( + device, + neighbors=None, + vrf="default", + AS_N=None, + ip="ipv4", + max_time=60, + check_interval=10, +): + """Verify active EIGRP neighbors for ipv4 (Default) and ipv6 for AS and VRF + Args: + device (obj): Device object + neighbors = None (list): Active EIGRP neighbors to check + vrf = "default" (str) : Name of the vrf + AS_N = None (int) : Autonomous System + ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" + max_time (`int`): Max time, default: 30 + check_interval (`int`): Check interval, default: 10 + + Returns: + True + False + """ + assert isinstance(AS_N, int), "AS_N must be int" + assert isinstance(vrf, str), "vrf must be str" + assert isinstance(neighbors, list), "neighbors must be list of interfaces" + assert AS_N != 0, "AS_N must not be 0" + assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" + timeout = Timeout(max_time, check_interval) + while timeout.iterate(): + if AS_N and neighbors: + try: + response = device.parse( + f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp neighbors" + ) + except SchemaEmptyParserError: + timeout.sleep() + continue + eigrp_neighbors = [] + if (vrf not in response.q.get_values("vrf")) or ( + str(AS_N) not in response.q.get_values("eigrp_instance") + ): + log.error( + f"Sorry, no data for the provided 'AS = {AS_N}' and/or 'vrf = {vrf}' !" + ) + else: + eigrp_neighbors = ( + response.q.contains_key_value("eigrp_instance", str(AS_N)) + .contains(vrf) + .contains(ip) + .get_values("eigrp_nbr") + ) + return set(neighbors).issubset(eigrp_neighbors) + log.error(f"Please, provide a valid format for AS, Neighbors, ip and/or vrf") + continue + +def verify_eigrp_router_id( + device, + router_id=None, + vrf="default", + auto_sys=None, + ip="ipv4", + max_time=60, + check_interval=10, +): + """verify EIGRP IDs for a given vrf and auto_sys active instance for ipv4 or ipv6 + Args: + device (obj): Device object + router_id = None (list): List of router ID to check + vrf = "default" (str): Name of the vrf by default set to "default" + auto_sys = None (int) : Autonomous System + ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" + max_time (`int`): Max time, default: 30 + check_interval (`int`): Check interval, default: 10 + + Returns: + True + False + """ + assert isinstance(auto_sys, int), "auto_sys must be int" + assert isinstance(vrf, str), "vrf must be str" + assert isinstance(router_id, list), "router_id must be list of router IDs" + assert auto_sys != 0, "auto_sys must not be 0" + assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" + timeout = Timeout(max_time, check_interval) + while timeout.iterate(): + if auto_sys and router_id: + try: + response = device.parse( + f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp topology" + ) + except SchemaEmptyParserError: + timeout.sleep() + continue + eigrp_id = [] + if (vrf not in response.q.get_values("vrf")) or ( + str(auto_sys) not in response.q.get_values("eigrp_instance") + ): + log.error( + f"Sorry, no data for the provided for 'auto_sys = {auto_sys}' and/or 'vrf = {vrf}'" + ) + else: + eigrp_id = ( + response.q.contains_key_value("eigrp_instance", str(auto_sys)) + .contains(vrf) + .contains((ip[0:2]).upper() + ip[2:]) + .get_values("eigrp_id") + ) + return set(router_id).issubset(eigrp_id) + log.error(f"Please, provid a valid format for auto_sys, router_id, vrf and/or ip") + continue + +def verify_eigrp_interfaces_timers( + device, + timers_dict=None, + vrf="default", + auto_sys=None, + ip="ipv4", + max_time=60, + check_interval=10, +): + """Verify hello interval and hold time of interfaces for a given vrf and active auto_sys for ipv4 or ipv6 + Args: + device (obj): Device object + timers_dict (dict): dict to verify containing interfaces with their hello interval and hold time + # ex.) timers_dict = {'FastEthernet0/0': [{'hello_interval': 5}, {'hold_time': 15}]} + vrf (str) : Name of the vrf by default set to "default" + auto_sys (int) : Autonomous System + ip = "ipv4" (str): Protocol ip, default: "ipv4" to change to "ipv6" + max_time (`int`): Max time, default: 30 + check_interval (`int`): Check interval, default: 10 + Returns: + True + False + """ + assert isinstance(auto_sys, int), "auto_sys must be int" + assert isinstance(vrf, str), "vrf must be str" + assert isinstance(timers_dict, dict), "timers_dict must be dict" + assert auto_sys != 0, "auto_sys must not be 0" + assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" + timeout = Timeout(max_time, check_interval) + while timeout.iterate(): + if auto_sys and timers_dict: + try: + response = device.parse( + f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp interfaces detail" + ) + except SchemaEmptyParserError: + timeout.sleep() + continue + inter_timers = {} + if (vrf not in response.q.get_values("vrf")) or ( + str(auto_sys) not in response.q.get_values("eigrp_instance") + ): + log.error( + f"Sorry, no data for the provided for 'auto_sys = {auto_sys}' and/or 'vrf = {vrf}'" + ) + else: + interfaces = ( + response.q.contains(vrf) + .contains_key_value("eigrp_instance", str(auto_sys)) + .contains(ip) + .get_values("interface") + ) + for interface in interfaces: + hello_interval = { + "hello_interval": ( + response.q.contains(interface).get_values("hello_interval") + )[0] + } + hold_time = { + "hold_time": ( + response.q.contains(interface).get_values("hold_time") + )[0] + } + inter_timers[interface] = [hello_interval, hold_time] + print(inter_timers) + return set(timers_dict).issubset(inter_timers) + log.error( + f"Please, provide a valid format for auto_sys, timers_dict, vrf and/or ip" + ) + continue From 870cde5e714e99862fe8c52c7242cf3288decf14 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Fri, 19 Apr 2024 19:47:38 +0100 Subject: [PATCH 07/39] Add files via upload Add changelog_add_verify_eigrp_interfaces_timers_apis_202419041835 --- ...add_verify_eigrp_interfaces_timers_apis_202419041835.rst | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 pkgs/sdk-pkg/changelog/changelog_add_verify_eigrp_interfaces_timers_apis_202419041835.rst diff --git a/pkgs/sdk-pkg/changelog/changelog_add_verify_eigrp_interfaces_timers_apis_202419041835.rst b/pkgs/sdk-pkg/changelog/changelog_add_verify_eigrp_interfaces_timers_apis_202419041835.rst new file mode 100644 index 000000000..de2947695 --- /dev/null +++ b/pkgs/sdk-pkg/changelog/changelog_add_verify_eigrp_interfaces_timers_apis_202419041835.rst @@ -0,0 +1,6 @@ +-------------------------------------------------------------------------------- + New +-------------------------------------------------------------------------------- +* IOSXE + * Added verify_eigrp_interfaces_timers to verify.py: + * New API supporting IPv4 and IPv6 to verify EIGRP interfaces timers \ No newline at end of file From 3b1c8aa45a276e1783f2cb515b1aea48ba09426b Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Thu, 9 May 2024 15:44:14 +0100 Subject: [PATCH 08/39] Update verify.py The change according to comments and suggestions --- pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py index 427e44a1a..9c55b5346 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py @@ -199,8 +199,7 @@ def verify_eigrp_interfaces_timers( max_time (`int`): Max time, default: 30 check_interval (`int`): Check interval, default: 10 Returns: - True - False + result (`bool`): Verified result """ assert isinstance(auto_sys, int), "auto_sys must be int" assert isinstance(vrf, str), "vrf must be str" @@ -243,7 +242,6 @@ def verify_eigrp_interfaces_timers( )[0] } inter_timers[interface] = [hello_interval, hold_time] - print(inter_timers) return set(timers_dict).issubset(inter_timers) log.error( f"Please, provide a valid format for auto_sys, timers_dict, vrf and/or ip" From d0a3049db243e3a2d8763e9d501cb4083891f03a Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Thu, 9 May 2024 15:47:03 +0100 Subject: [PATCH 09/39] Update mock_data.yaml The change to add "show version | include operating mode: ''" --- .../mock_data/iosxe/mock_data.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml index 5f7244bd1..105458fab 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml @@ -52,6 +52,7 @@ execute: \ 0\r\n Topology-ids on interface - 0 \r\n Authentication mode is not set" response_type: circular show version: '' + show version | include operating mode: '' term length 0: '' term width 0: '' prompt: R1# From 3392b4738e95ff78b9fc929b0cbe931ef3530eec Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Thu, 9 May 2024 16:00:37 +0100 Subject: [PATCH 10/39] Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml --- .../mock_data/iosxe/mock_data.yaml | 58 ------------------- 1 file changed, 58 deletions(-) delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 105458fab..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,58 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - prompt: R1(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: R1(config-line)# -connect: - commands: - ? '' - : new_state: execute - preface: 'Trying mock_device ... - - Connected to mock_device. - - Escape character is ''^]''.' - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show ip eigrp interfaces detail: - response: - - "EIGRP-IPv4 Interfaces for AS(1)\r\n Xmit Queue\ - \ PeerQ Mean Pacing Time Multicast Pending\r\nInterface \ - \ Peers Un/Reliable Un/Reliable SRTT Un/Reliable Flow Timer\ - \ Routes\r\nFa0/0 1 0/0 0/0 32\ - \ 0/0 50 0\r\n Hello-interval is 5, Hold-time is\ - \ 15\r\n Split-horizon is enabled\r\n Next xmit serial \r\n Packetized\ - \ sent/expedited: 1/0\r\n Hello's sent/expedited: 303/2\r\n Un/reliable\ - \ mcasts: 0/1 Un/reliable ucasts: 1/2\r\n Mcast exceptions: 0 CR packets:\ - \ 0 ACKs suppressed: 0\r\n Retransmissions sent: 1 Out-of-sequence rcvd:\ - \ 1\r\n Topology-ids on interface - 0 \r\n Authentication mode is not set\r\ - \nEIGRP-IPv4 Interfaces for AS(2)\r\n Xmit Queue\ - \ PeerQ Mean Pacing Time Multicast Pending\r\nInterface \ - \ Peers Un/Reliable Un/Reliable SRTT Un/Reliable Flow Timer\ - \ Routes\r\nFa1/0 0 0/0 0/0 0\ - \ 0/0 0 0\r\n Hello-interval is 5, Hold-time is\ - \ 15\r\n Split-horizon is enabled\r\n Next xmit serial \r\n Packetized\ - \ sent/expedited: 0/0\r\n Hello's sent/expedited: 304/1\r\n Un/reliable\ - \ mcasts: 0/0 Un/reliable ucasts: 0/0\r\n Mcast exceptions: 0 CR packets:\ - \ 0 ACKs suppressed: 0\r\n Retransmissions sent: 0 Out-of-sequence rcvd:\ - \ 0\r\n Topology-ids on interface - 0 \r\n Authentication mode is not set" - response_type: circular - show version: '' - show version | include operating mode: '' - term length 0: '' - term width 0: '' - prompt: R1# From d7fb35880b6faf6eb37baf985135a2c1d8b7a5a0 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Thu, 9 May 2024 16:01:35 +0100 Subject: [PATCH 11/39] Create tst --- .../verify/verify_eigrp_interfaces_timers/mock_data/iosxe/tst | 1 + 1 file changed, 1 insertion(+) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/tst diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/tst b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/tst new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/tst @@ -0,0 +1 @@ + From b23019b34eb2925ab99b2994b7ca2dfe9d8b727a Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Thu, 9 May 2024 16:02:06 +0100 Subject: [PATCH 12/39] Add files via upload --- .../mock_data/iosxe/mock_data.yaml | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml new file mode 100644 index 000000000..105458fab --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml @@ -0,0 +1,58 @@ +configure: + commands: + end: + new_state: execute + line console 0: + new_state: configure_line + no logging console: '' + prompt: R1(config)# +configure_line: + commands: + end: + new_state: execute + exec-timeout 0: '' + prompt: R1(config-line)# +connect: + commands: + ? '' + : new_state: execute + preface: 'Trying mock_device ... + + Connected to mock_device. + + Escape character is ''^]''.' + prompt: '' +execute: + commands: + config term: + new_state: configure + config-transaction: + new_state: configure + show ip eigrp interfaces detail: + response: + - "EIGRP-IPv4 Interfaces for AS(1)\r\n Xmit Queue\ + \ PeerQ Mean Pacing Time Multicast Pending\r\nInterface \ + \ Peers Un/Reliable Un/Reliable SRTT Un/Reliable Flow Timer\ + \ Routes\r\nFa0/0 1 0/0 0/0 32\ + \ 0/0 50 0\r\n Hello-interval is 5, Hold-time is\ + \ 15\r\n Split-horizon is enabled\r\n Next xmit serial \r\n Packetized\ + \ sent/expedited: 1/0\r\n Hello's sent/expedited: 303/2\r\n Un/reliable\ + \ mcasts: 0/1 Un/reliable ucasts: 1/2\r\n Mcast exceptions: 0 CR packets:\ + \ 0 ACKs suppressed: 0\r\n Retransmissions sent: 1 Out-of-sequence rcvd:\ + \ 1\r\n Topology-ids on interface - 0 \r\n Authentication mode is not set\r\ + \nEIGRP-IPv4 Interfaces for AS(2)\r\n Xmit Queue\ + \ PeerQ Mean Pacing Time Multicast Pending\r\nInterface \ + \ Peers Un/Reliable Un/Reliable SRTT Un/Reliable Flow Timer\ + \ Routes\r\nFa1/0 0 0/0 0/0 0\ + \ 0/0 0 0\r\n Hello-interval is 5, Hold-time is\ + \ 15\r\n Split-horizon is enabled\r\n Next xmit serial \r\n Packetized\ + \ sent/expedited: 0/0\r\n Hello's sent/expedited: 304/1\r\n Un/reliable\ + \ mcasts: 0/0 Un/reliable ucasts: 0/0\r\n Mcast exceptions: 0 CR packets:\ + \ 0 ACKs suppressed: 0\r\n Retransmissions sent: 0 Out-of-sequence rcvd:\ + \ 0\r\n Topology-ids on interface - 0 \r\n Authentication mode is not set" + response_type: circular + show version: '' + show version | include operating mode: '' + term length 0: '' + term width 0: '' + prompt: R1# From 91d77df58a8c392c74d8eda7ef7e39f4f4f0dec0 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Thu, 9 May 2024 16:03:06 +0100 Subject: [PATCH 13/39] Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/tst --- .../verify/verify_eigrp_interfaces_timers/mock_data/iosxe/tst | 1 - 1 file changed, 1 deletion(-) delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/tst diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/tst b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/tst deleted file mode 100644 index 8b1378917..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/tst +++ /dev/null @@ -1 +0,0 @@ - From 9aa5f43090b545af0d7c29c8ade7dbd98ed35221 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Thu, 9 May 2024 16:14:09 +0100 Subject: [PATCH 14/39] Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py Delete old one --- .../genie/libs/sdk/apis/iosxe/eigrp/verify.py | 249 ------------------ 1 file changed, 249 deletions(-) delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py deleted file mode 100644 index 9c55b5346..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py +++ /dev/null @@ -1,249 +0,0 @@ -from genie.utils.timeout import Timeout -import logging -import os -from genie.metaparser.util.exceptions import SchemaEmptyParserError - -log = logging.getLogger(__name__) - - -def verify_eigrp_interfaces( - device, - vrf="default", - AS_N=None, - interfaces_list=None, - ip="ipv4", - max_time=60, - check_interval=10, -): - """Verify active EIGRP interfaces for ipv4 (Default) or ipv6 for AS and VRF - Args: - device (obj): Device object - vrf = "default" (str): Name of the vrf by default set to "default" - AS_N = None (int): Autonomous System - interfaces_list = None (list): List of active EIGRP interfaces to check - ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" - max_time (`int`): Max time, default: 30 - check_interval (`int`): Check interval, default: 10 - - Returns: - True - False - """ - assert isinstance(AS_N, int), "AS_N must be int" - assert isinstance(vrf, str), "vrf must be str" - assert isinstance( - interfaces_list, list - ), "interfaces_list must be list of interfaces" - assert AS_N != 0, "AS_N must not be 0" - assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" - timeout = Timeout(max_time, check_interval) - while timeout.iterate(): - if AS_N and interfaces_list: - try: - response = device.parse( - f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp interfaces" - ) - except SchemaEmptyParserError: - timeout.sleep() - continue - interfaces = [] - if (vrf not in response.q.get_values("vrf")) or ( - str(AS_N) not in response.q.get_values("eigrp_instance") - ): - log.error( - f"Sorry,no data for the provided 'AS = {AS_N}' and/or 'vrf = {vrf}' !" - ) - else: - interfaces = ( - response.q.contains(vrf) - .contains_key_value("eigrp_instance", str(AS_N)) - .contains(ip) - .get_values("interface") - ) - return set(interfaces_list).issubset(interfaces) - log.error( - f"Please, provide a valid format for AS, interfaces_list, ip and/or vrf" - ) - continue - - -def verify_eigrp_neighbors( - device, - neighbors=None, - vrf="default", - AS_N=None, - ip="ipv4", - max_time=60, - check_interval=10, -): - """Verify active EIGRP neighbors for ipv4 (Default) and ipv6 for AS and VRF - Args: - device (obj): Device object - neighbors = None (list): Active EIGRP neighbors to check - vrf = "default" (str) : Name of the vrf - AS_N = None (int) : Autonomous System - ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" - max_time (`int`): Max time, default: 30 - check_interval (`int`): Check interval, default: 10 - - Returns: - True - False - """ - assert isinstance(AS_N, int), "AS_N must be int" - assert isinstance(vrf, str), "vrf must be str" - assert isinstance(neighbors, list), "neighbors must be list of interfaces" - assert AS_N != 0, "AS_N must not be 0" - assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" - timeout = Timeout(max_time, check_interval) - while timeout.iterate(): - if AS_N and neighbors: - try: - response = device.parse( - f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp neighbors" - ) - except SchemaEmptyParserError: - timeout.sleep() - continue - eigrp_neighbors = [] - if (vrf not in response.q.get_values("vrf")) or ( - str(AS_N) not in response.q.get_values("eigrp_instance") - ): - log.error( - f"Sorry, no data for the provided 'AS = {AS_N}' and/or 'vrf = {vrf}' !" - ) - else: - eigrp_neighbors = ( - response.q.contains_key_value("eigrp_instance", str(AS_N)) - .contains(vrf) - .contains(ip) - .get_values("eigrp_nbr") - ) - return set(neighbors).issubset(eigrp_neighbors) - log.error(f"Please, provide a valid format for AS, Neighbors, ip and/or vrf") - continue - -def verify_eigrp_router_id( - device, - router_id=None, - vrf="default", - auto_sys=None, - ip="ipv4", - max_time=60, - check_interval=10, -): - """verify EIGRP IDs for a given vrf and auto_sys active instance for ipv4 or ipv6 - Args: - device (obj): Device object - router_id = None (list): List of router ID to check - vrf = "default" (str): Name of the vrf by default set to "default" - auto_sys = None (int) : Autonomous System - ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" - max_time (`int`): Max time, default: 30 - check_interval (`int`): Check interval, default: 10 - - Returns: - True - False - """ - assert isinstance(auto_sys, int), "auto_sys must be int" - assert isinstance(vrf, str), "vrf must be str" - assert isinstance(router_id, list), "router_id must be list of router IDs" - assert auto_sys != 0, "auto_sys must not be 0" - assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" - timeout = Timeout(max_time, check_interval) - while timeout.iterate(): - if auto_sys and router_id: - try: - response = device.parse( - f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp topology" - ) - except SchemaEmptyParserError: - timeout.sleep() - continue - eigrp_id = [] - if (vrf not in response.q.get_values("vrf")) or ( - str(auto_sys) not in response.q.get_values("eigrp_instance") - ): - log.error( - f"Sorry, no data for the provided for 'auto_sys = {auto_sys}' and/or 'vrf = {vrf}'" - ) - else: - eigrp_id = ( - response.q.contains_key_value("eigrp_instance", str(auto_sys)) - .contains(vrf) - .contains((ip[0:2]).upper() + ip[2:]) - .get_values("eigrp_id") - ) - return set(router_id).issubset(eigrp_id) - log.error(f"Please, provid a valid format for auto_sys, router_id, vrf and/or ip") - continue - -def verify_eigrp_interfaces_timers( - device, - timers_dict=None, - vrf="default", - auto_sys=None, - ip="ipv4", - max_time=60, - check_interval=10, -): - """Verify hello interval and hold time of interfaces for a given vrf and active auto_sys for ipv4 or ipv6 - Args: - device (obj): Device object - timers_dict (dict): dict to verify containing interfaces with their hello interval and hold time - # ex.) timers_dict = {'FastEthernet0/0': [{'hello_interval': 5}, {'hold_time': 15}]} - vrf (str) : Name of the vrf by default set to "default" - auto_sys (int) : Autonomous System - ip = "ipv4" (str): Protocol ip, default: "ipv4" to change to "ipv6" - max_time (`int`): Max time, default: 30 - check_interval (`int`): Check interval, default: 10 - Returns: - result (`bool`): Verified result - """ - assert isinstance(auto_sys, int), "auto_sys must be int" - assert isinstance(vrf, str), "vrf must be str" - assert isinstance(timers_dict, dict), "timers_dict must be dict" - assert auto_sys != 0, "auto_sys must not be 0" - assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" - timeout = Timeout(max_time, check_interval) - while timeout.iterate(): - if auto_sys and timers_dict: - try: - response = device.parse( - f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp interfaces detail" - ) - except SchemaEmptyParserError: - timeout.sleep() - continue - inter_timers = {} - if (vrf not in response.q.get_values("vrf")) or ( - str(auto_sys) not in response.q.get_values("eigrp_instance") - ): - log.error( - f"Sorry, no data for the provided for 'auto_sys = {auto_sys}' and/or 'vrf = {vrf}'" - ) - else: - interfaces = ( - response.q.contains(vrf) - .contains_key_value("eigrp_instance", str(auto_sys)) - .contains(ip) - .get_values("interface") - ) - for interface in interfaces: - hello_interval = { - "hello_interval": ( - response.q.contains(interface).get_values("hello_interval") - )[0] - } - hold_time = { - "hold_time": ( - response.q.contains(interface).get_values("hold_time") - )[0] - } - inter_timers[interface] = [hello_interval, hold_time] - return set(timers_dict).issubset(inter_timers) - log.error( - f"Please, provide a valid format for auto_sys, timers_dict, vrf and/or ip" - ) - continue From f2695100de8478a1a7dfd6b79870a22696754984 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Thu, 9 May 2024 16:14:48 +0100 Subject: [PATCH 15/39] Add files via upload New with suggested modification --- .../genie/libs/sdk/apis/iosxe/eigrp/verify.py | 251 ++++++++++++++++++ 1 file changed, 251 insertions(+) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py new file mode 100644 index 000000000..93bcb243a --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py @@ -0,0 +1,251 @@ +from genie.utils.timeout import Timeout +import logging +import os +from genie.metaparser.util.exceptions import SchemaEmptyParserError + +log = logging.getLogger(__name__) + + +def verify_eigrp_interfaces( + device, + vrf="default", + AS_N=None, + interfaces_list=None, + ip="ipv4", + max_time=60, + check_interval=10, +): + """Verify active EIGRP interfaces for ipv4 (Default) or ipv6 for AS and VRF + Args: + device (obj): Device object + vrf = "default" (str): Name of the vrf by default set to "default" + AS_N = None (int): Autonomous System + interfaces_list = None (list): List of active EIGRP interfaces to check + ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" + max_time (`int`): Max time, default: 30 + check_interval (`int`): Check interval, default: 10 + + Returns: + True + False + """ + assert isinstance(AS_N, int), "AS_N must be int" + assert isinstance(vrf, str), "vrf must be str" + assert isinstance( + interfaces_list, list + ), "interfaces_list must be list of interfaces" + assert AS_N != 0, "AS_N must not be 0" + assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" + timeout = Timeout(max_time, check_interval) + while timeout.iterate(): + if AS_N and interfaces_list: + try: + response = device.parse( + f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp interfaces" + ) + except SchemaEmptyParserError: + timeout.sleep() + continue + interfaces = [] + if (vrf not in response.q.get_values("vrf")) or ( + str(AS_N) not in response.q.get_values("eigrp_instance") + ): + log.error( + f"Sorry,no data for the provided 'AS = {AS_N}' and/or 'vrf = {vrf}' !" + ) + else: + interfaces = ( + response.q.contains(vrf) + .contains_key_value("eigrp_instance", str(AS_N)) + .contains(ip) + .get_values("interface") + ) + return set(interfaces_list).issubset(interfaces) + log.error( + f"Please, provide a valid format for AS, interfaces_list, ip and/or vrf" + ) + continue + + +def verify_eigrp_neighbors( + device, + neighbors=None, + vrf="default", + AS_N=None, + ip="ipv4", + max_time=60, + check_interval=10, +): + """Verify active EIGRP neighbors for ipv4 (Default) and ipv6 for AS and VRF + Args: + device (obj): Device object + neighbors = None (list): Active EIGRP neighbors to check + vrf = "default" (str) : Name of the vrf + AS_N = None (int) : Autonomous System + ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" + max_time (`int`): Max time, default: 30 + check_interval (`int`): Check interval, default: 10 + + Returns: + True + False + """ + assert isinstance(AS_N, int), "AS_N must be int" + assert isinstance(vrf, str), "vrf must be str" + assert isinstance(neighbors, list), "neighbors must be list of interfaces" + assert AS_N != 0, "AS_N must not be 0" + assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" + timeout = Timeout(max_time, check_interval) + while timeout.iterate(): + if AS_N and neighbors: + try: + response = device.parse( + f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp neighbors" + ) + except SchemaEmptyParserError: + timeout.sleep() + continue + eigrp_neighbors = [] + if (vrf not in response.q.get_values("vrf")) or ( + str(AS_N) not in response.q.get_values("eigrp_instance") + ): + log.error( + f"Sorry, no data for the provided 'AS = {AS_N}' and/or 'vrf = {vrf}' !" + ) + else: + eigrp_neighbors = ( + response.q.contains_key_value("eigrp_instance", str(AS_N)) + .contains(vrf) + .contains(ip) + .get_values("eigrp_nbr") + ) + return set(neighbors).issubset(eigrp_neighbors) + log.error(f"Please, provide a valid format for AS, Neighbors, ip and/or vrf") + continue + +def verify_eigrp_router_id( + device, + router_id=None, + vrf="default", + auto_sys=None, + ip="ipv4", + max_time=60, + check_interval=10, +): + """verify EIGRP IDs for a given vrf and auto_sys active instance for ipv4 or ipv6 + Args: + device (obj): Device object + router_id = None (list): List of router ID to check + vrf = "default" (str): Name of the vrf by default set to "default" + auto_sys = None (int) : Autonomous System + ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" + max_time (`int`): Max time, default: 30 + check_interval (`int`): Check interval, default: 10 + + Returns: + True + False + """ + assert isinstance(auto_sys, int), "auto_sys must be int" + assert isinstance(vrf, str), "vrf must be str" + assert isinstance(router_id, list), "router_id must be list of router IDs" + assert auto_sys != 0, "auto_sys must not be 0" + assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" + timeout = Timeout(max_time, check_interval) + while timeout.iterate(): + if auto_sys and router_id: + try: + response = device.parse( + f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp topology" + ) + except SchemaEmptyParserError: + timeout.sleep() + continue + eigrp_id = [] + if (vrf not in response.q.get_values("vrf")) or ( + str(auto_sys) not in response.q.get_values("eigrp_instance") + ): + log.error( + f"Sorry, no data for the provided for 'auto_sys = {auto_sys}' and/or 'vrf = {vrf}'" + ) + else: + eigrp_id = ( + response.q.contains_key_value("eigrp_instance", str(auto_sys)) + .contains(vrf) + .contains((ip[0:2]).upper() + ip[2:]) + .get_values("eigrp_id") + ) + return set(router_id).issubset(eigrp_id) + log.error(f"Please, provid a valid format for auto_sys, router_id, vrf and/or ip") + continue + +def verify_eigrp_interfaces_timers( + device, + timers_dict=None, + vrf="default", + auto_sys=None, + ip="ipv4", + max_time=60, + check_interval=10, +): + """Verify hello interval and hold time of interfaces for a given vrf and active auto_sys for ipv4 or ipv6 + Args: + device (obj): Device object + timers_dict (dict): dict to verify containing interfaces with their hello interval and hold time + # ex.) timers_dict = {'FastEthernet0/0': [{'hello_interval': 5}, {'hold_time': 15}]} + vrf (str) : Name of the vrf by default set to "default" + auto_sys (int) : Autonomous System + ip = "ipv4" (str): Protocol ip, default: "ipv4" to change to "ipv6" + max_time (`int`): Max time, default: 30 + check_interval (`int`): Check interval, default: 10 + Returns: + result (bool): Verified result + True + False + """ + assert isinstance(auto_sys, int), "auto_sys must be int" + assert isinstance(vrf, str), "vrf must be str" + assert isinstance(timers_dict, dict), "timers_dict must be dict" + assert auto_sys != 0, "auto_sys must not be 0" + assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" + timeout = Timeout(max_time, check_interval) + while timeout.iterate(): + if auto_sys and timers_dict: + try: + response = device.parse( + f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp interfaces detail" + ) + except SchemaEmptyParserError: + timeout.sleep() + continue + inter_timers = {} + if (vrf not in response.q.get_values("vrf")) or ( + str(auto_sys) not in response.q.get_values("eigrp_instance") + ): + log.error( + f"Sorry, no data for the provided for 'auto_sys = {auto_sys}' and/or 'vrf = {vrf}'" + ) + else: + interfaces = ( + response.q.contains(vrf) + .contains_key_value("eigrp_instance", str(auto_sys)) + .contains(ip) + .get_values("interface") + ) + for interface in interfaces: + hello_interval = { + "hello_interval": ( + response.q.contains(interface).get_values("hello_interval") + )[0] + } + hold_time = { + "hold_time": ( + response.q.contains(interface).get_values("hold_time") + )[0] + } + inter_timers[interface] = [hello_interval, hold_time] + return set(timers_dict).issubset(inter_timers) + log.error( + f"Please, provide a valid format for auto_sys, timers_dict, vrf and/or ip" + ) + continue From e371ca7d4b8024ff73e82c63379903eedd0d7dda Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Thu, 9 May 2024 16:19:57 +0100 Subject: [PATCH 16/39] Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe directory --- .../mock_data/iosxe/mock_data.yaml | 58 ------------------- 1 file changed, 58 deletions(-) delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 105458fab..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,58 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - prompt: R1(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: R1(config-line)# -connect: - commands: - ? '' - : new_state: execute - preface: 'Trying mock_device ... - - Connected to mock_device. - - Escape character is ''^]''.' - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show ip eigrp interfaces detail: - response: - - "EIGRP-IPv4 Interfaces for AS(1)\r\n Xmit Queue\ - \ PeerQ Mean Pacing Time Multicast Pending\r\nInterface \ - \ Peers Un/Reliable Un/Reliable SRTT Un/Reliable Flow Timer\ - \ Routes\r\nFa0/0 1 0/0 0/0 32\ - \ 0/0 50 0\r\n Hello-interval is 5, Hold-time is\ - \ 15\r\n Split-horizon is enabled\r\n Next xmit serial \r\n Packetized\ - \ sent/expedited: 1/0\r\n Hello's sent/expedited: 303/2\r\n Un/reliable\ - \ mcasts: 0/1 Un/reliable ucasts: 1/2\r\n Mcast exceptions: 0 CR packets:\ - \ 0 ACKs suppressed: 0\r\n Retransmissions sent: 1 Out-of-sequence rcvd:\ - \ 1\r\n Topology-ids on interface - 0 \r\n Authentication mode is not set\r\ - \nEIGRP-IPv4 Interfaces for AS(2)\r\n Xmit Queue\ - \ PeerQ Mean Pacing Time Multicast Pending\r\nInterface \ - \ Peers Un/Reliable Un/Reliable SRTT Un/Reliable Flow Timer\ - \ Routes\r\nFa1/0 0 0/0 0/0 0\ - \ 0/0 0 0\r\n Hello-interval is 5, Hold-time is\ - \ 15\r\n Split-horizon is enabled\r\n Next xmit serial \r\n Packetized\ - \ sent/expedited: 0/0\r\n Hello's sent/expedited: 304/1\r\n Un/reliable\ - \ mcasts: 0/0 Un/reliable ucasts: 0/0\r\n Mcast exceptions: 0 CR packets:\ - \ 0 ACKs suppressed: 0\r\n Retransmissions sent: 0 Out-of-sequence rcvd:\ - \ 0\r\n Topology-ids on interface - 0 \r\n Authentication mode is not set" - response_type: circular - show version: '' - show version | include operating mode: '' - term length 0: '' - term width 0: '' - prompt: R1# From e791a692fbec8f1cc6692178de59a65e36357fb6 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Thu, 9 May 2024 16:20:22 +0100 Subject: [PATCH 17/39] Create tst --- .../verify/verify_eigrp_interfaces_timers/mock_data/iosxe/tst | 1 + 1 file changed, 1 insertion(+) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/tst diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/tst b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/tst new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/tst @@ -0,0 +1 @@ + From 3462971de10e9c4b68a8fba530877059867a6171 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Thu, 9 May 2024 16:21:14 +0100 Subject: [PATCH 18/39] Add files via upload --- .../mock_data/iosxe/mock_data.yaml | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml new file mode 100644 index 000000000..105458fab --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml @@ -0,0 +1,58 @@ +configure: + commands: + end: + new_state: execute + line console 0: + new_state: configure_line + no logging console: '' + prompt: R1(config)# +configure_line: + commands: + end: + new_state: execute + exec-timeout 0: '' + prompt: R1(config-line)# +connect: + commands: + ? '' + : new_state: execute + preface: 'Trying mock_device ... + + Connected to mock_device. + + Escape character is ''^]''.' + prompt: '' +execute: + commands: + config term: + new_state: configure + config-transaction: + new_state: configure + show ip eigrp interfaces detail: + response: + - "EIGRP-IPv4 Interfaces for AS(1)\r\n Xmit Queue\ + \ PeerQ Mean Pacing Time Multicast Pending\r\nInterface \ + \ Peers Un/Reliable Un/Reliable SRTT Un/Reliable Flow Timer\ + \ Routes\r\nFa0/0 1 0/0 0/0 32\ + \ 0/0 50 0\r\n Hello-interval is 5, Hold-time is\ + \ 15\r\n Split-horizon is enabled\r\n Next xmit serial \r\n Packetized\ + \ sent/expedited: 1/0\r\n Hello's sent/expedited: 303/2\r\n Un/reliable\ + \ mcasts: 0/1 Un/reliable ucasts: 1/2\r\n Mcast exceptions: 0 CR packets:\ + \ 0 ACKs suppressed: 0\r\n Retransmissions sent: 1 Out-of-sequence rcvd:\ + \ 1\r\n Topology-ids on interface - 0 \r\n Authentication mode is not set\r\ + \nEIGRP-IPv4 Interfaces for AS(2)\r\n Xmit Queue\ + \ PeerQ Mean Pacing Time Multicast Pending\r\nInterface \ + \ Peers Un/Reliable Un/Reliable SRTT Un/Reliable Flow Timer\ + \ Routes\r\nFa1/0 0 0/0 0/0 0\ + \ 0/0 0 0\r\n Hello-interval is 5, Hold-time is\ + \ 15\r\n Split-horizon is enabled\r\n Next xmit serial \r\n Packetized\ + \ sent/expedited: 0/0\r\n Hello's sent/expedited: 304/1\r\n Un/reliable\ + \ mcasts: 0/0 Un/reliable ucasts: 0/0\r\n Mcast exceptions: 0 CR packets:\ + \ 0 ACKs suppressed: 0\r\n Retransmissions sent: 0 Out-of-sequence rcvd:\ + \ 0\r\n Topology-ids on interface - 0 \r\n Authentication mode is not set" + response_type: circular + show version: '' + show version | include operating mode: '' + term length 0: '' + term width 0: '' + prompt: R1# From ab3a82fe9df82cb5d6adc584c6d6cd2e5787089c Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Thu, 9 May 2024 16:21:51 +0100 Subject: [PATCH 19/39] Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/tst --- .../verify/verify_eigrp_interfaces_timers/mock_data/iosxe/tst | 1 - 1 file changed, 1 deletion(-) delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/tst diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/tst b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/tst deleted file mode 100644 index 8b1378917..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/tst +++ /dev/null @@ -1 +0,0 @@ - From a4f1b96765d8d7cbebe8c7ac72634a9cbd007102 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Thu, 9 May 2024 16:40:24 +0100 Subject: [PATCH 20/39] Update pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml Co-authored-by: Douglas Monteiro <84336224+domachad@users.noreply.github.com> --- .../mock_data/iosxe/mock_data.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml index 105458fab..8bf541349 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml @@ -53,6 +53,7 @@ execute: response_type: circular show version: '' show version | include operating mode: '' + show version | include operating mode: '' term length 0: '' term width 0: '' prompt: R1# From c7ef175e82e6e7e2ba108ee8cbf0d51bc67d3410 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Thu, 9 May 2024 16:50:14 +0100 Subject: [PATCH 21/39] Update mock_data.yaml --- .../mock_data/iosxe/mock_data.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml index 8bf541349..105458fab 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml @@ -53,7 +53,6 @@ execute: response_type: circular show version: '' show version | include operating mode: '' - show version | include operating mode: '' term length 0: '' term width 0: '' prompt: R1# From 466db60b4f4c5acc21cd327f3e628214eb049a38 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Thu, 9 May 2024 16:57:39 +0100 Subject: [PATCH 22/39] Update mock_data.yaml --- .../mock_data/iosxe/mock_data.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml index 105458fab..5f7244bd1 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml @@ -52,7 +52,6 @@ execute: \ 0\r\n Topology-ids on interface - 0 \r\n Authentication mode is not set" response_type: circular show version: '' - show version | include operating mode: '' term length 0: '' term width 0: '' prompt: R1# From 0b461b8bb9aeff5535965b354862f1b6655a5d66 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Thu, 9 May 2024 17:02:05 +0100 Subject: [PATCH 23/39] Update pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml Co-authored-by: Douglas Monteiro <84336224+domachad@users.noreply.github.com> --- .../mock_data/iosxe/mock_data.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml index 5f7244bd1..105458fab 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml @@ -52,6 +52,7 @@ execute: \ 0\r\n Topology-ids on interface - 0 \r\n Authentication mode is not set" response_type: circular show version: '' + show version | include operating mode: '' term length 0: '' term width 0: '' prompt: R1# From b9b115cea74bb986704da5ff427219b2ccd1216f Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Thu, 9 May 2024 17:08:07 +0100 Subject: [PATCH 24/39] Update verify.py --- pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py index 93bcb243a..4f30fc769 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py @@ -200,8 +200,6 @@ def verify_eigrp_interfaces_timers( check_interval (`int`): Check interval, default: 10 Returns: result (bool): Verified result - True - False """ assert isinstance(auto_sys, int), "auto_sys must be int" assert isinstance(vrf, str), "vrf must be str" From 84761c9547acc8ff5b99fdad529ff6c504f1f5a7 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Thu, 9 May 2024 17:53:56 +0100 Subject: [PATCH 25/39] Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py --- .../genie/libs/sdk/apis/iosxe/eigrp/verify.py | 249 ------------------ 1 file changed, 249 deletions(-) delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py deleted file mode 100644 index 4f30fc769..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py +++ /dev/null @@ -1,249 +0,0 @@ -from genie.utils.timeout import Timeout -import logging -import os -from genie.metaparser.util.exceptions import SchemaEmptyParserError - -log = logging.getLogger(__name__) - - -def verify_eigrp_interfaces( - device, - vrf="default", - AS_N=None, - interfaces_list=None, - ip="ipv4", - max_time=60, - check_interval=10, -): - """Verify active EIGRP interfaces for ipv4 (Default) or ipv6 for AS and VRF - Args: - device (obj): Device object - vrf = "default" (str): Name of the vrf by default set to "default" - AS_N = None (int): Autonomous System - interfaces_list = None (list): List of active EIGRP interfaces to check - ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" - max_time (`int`): Max time, default: 30 - check_interval (`int`): Check interval, default: 10 - - Returns: - True - False - """ - assert isinstance(AS_N, int), "AS_N must be int" - assert isinstance(vrf, str), "vrf must be str" - assert isinstance( - interfaces_list, list - ), "interfaces_list must be list of interfaces" - assert AS_N != 0, "AS_N must not be 0" - assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" - timeout = Timeout(max_time, check_interval) - while timeout.iterate(): - if AS_N and interfaces_list: - try: - response = device.parse( - f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp interfaces" - ) - except SchemaEmptyParserError: - timeout.sleep() - continue - interfaces = [] - if (vrf not in response.q.get_values("vrf")) or ( - str(AS_N) not in response.q.get_values("eigrp_instance") - ): - log.error( - f"Sorry,no data for the provided 'AS = {AS_N}' and/or 'vrf = {vrf}' !" - ) - else: - interfaces = ( - response.q.contains(vrf) - .contains_key_value("eigrp_instance", str(AS_N)) - .contains(ip) - .get_values("interface") - ) - return set(interfaces_list).issubset(interfaces) - log.error( - f"Please, provide a valid format for AS, interfaces_list, ip and/or vrf" - ) - continue - - -def verify_eigrp_neighbors( - device, - neighbors=None, - vrf="default", - AS_N=None, - ip="ipv4", - max_time=60, - check_interval=10, -): - """Verify active EIGRP neighbors for ipv4 (Default) and ipv6 for AS and VRF - Args: - device (obj): Device object - neighbors = None (list): Active EIGRP neighbors to check - vrf = "default" (str) : Name of the vrf - AS_N = None (int) : Autonomous System - ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" - max_time (`int`): Max time, default: 30 - check_interval (`int`): Check interval, default: 10 - - Returns: - True - False - """ - assert isinstance(AS_N, int), "AS_N must be int" - assert isinstance(vrf, str), "vrf must be str" - assert isinstance(neighbors, list), "neighbors must be list of interfaces" - assert AS_N != 0, "AS_N must not be 0" - assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" - timeout = Timeout(max_time, check_interval) - while timeout.iterate(): - if AS_N and neighbors: - try: - response = device.parse( - f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp neighbors" - ) - except SchemaEmptyParserError: - timeout.sleep() - continue - eigrp_neighbors = [] - if (vrf not in response.q.get_values("vrf")) or ( - str(AS_N) not in response.q.get_values("eigrp_instance") - ): - log.error( - f"Sorry, no data for the provided 'AS = {AS_N}' and/or 'vrf = {vrf}' !" - ) - else: - eigrp_neighbors = ( - response.q.contains_key_value("eigrp_instance", str(AS_N)) - .contains(vrf) - .contains(ip) - .get_values("eigrp_nbr") - ) - return set(neighbors).issubset(eigrp_neighbors) - log.error(f"Please, provide a valid format for AS, Neighbors, ip and/or vrf") - continue - -def verify_eigrp_router_id( - device, - router_id=None, - vrf="default", - auto_sys=None, - ip="ipv4", - max_time=60, - check_interval=10, -): - """verify EIGRP IDs for a given vrf and auto_sys active instance for ipv4 or ipv6 - Args: - device (obj): Device object - router_id = None (list): List of router ID to check - vrf = "default" (str): Name of the vrf by default set to "default" - auto_sys = None (int) : Autonomous System - ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" - max_time (`int`): Max time, default: 30 - check_interval (`int`): Check interval, default: 10 - - Returns: - True - False - """ - assert isinstance(auto_sys, int), "auto_sys must be int" - assert isinstance(vrf, str), "vrf must be str" - assert isinstance(router_id, list), "router_id must be list of router IDs" - assert auto_sys != 0, "auto_sys must not be 0" - assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" - timeout = Timeout(max_time, check_interval) - while timeout.iterate(): - if auto_sys and router_id: - try: - response = device.parse( - f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp topology" - ) - except SchemaEmptyParserError: - timeout.sleep() - continue - eigrp_id = [] - if (vrf not in response.q.get_values("vrf")) or ( - str(auto_sys) not in response.q.get_values("eigrp_instance") - ): - log.error( - f"Sorry, no data for the provided for 'auto_sys = {auto_sys}' and/or 'vrf = {vrf}'" - ) - else: - eigrp_id = ( - response.q.contains_key_value("eigrp_instance", str(auto_sys)) - .contains(vrf) - .contains((ip[0:2]).upper() + ip[2:]) - .get_values("eigrp_id") - ) - return set(router_id).issubset(eigrp_id) - log.error(f"Please, provid a valid format for auto_sys, router_id, vrf and/or ip") - continue - -def verify_eigrp_interfaces_timers( - device, - timers_dict=None, - vrf="default", - auto_sys=None, - ip="ipv4", - max_time=60, - check_interval=10, -): - """Verify hello interval and hold time of interfaces for a given vrf and active auto_sys for ipv4 or ipv6 - Args: - device (obj): Device object - timers_dict (dict): dict to verify containing interfaces with their hello interval and hold time - # ex.) timers_dict = {'FastEthernet0/0': [{'hello_interval': 5}, {'hold_time': 15}]} - vrf (str) : Name of the vrf by default set to "default" - auto_sys (int) : Autonomous System - ip = "ipv4" (str): Protocol ip, default: "ipv4" to change to "ipv6" - max_time (`int`): Max time, default: 30 - check_interval (`int`): Check interval, default: 10 - Returns: - result (bool): Verified result - """ - assert isinstance(auto_sys, int), "auto_sys must be int" - assert isinstance(vrf, str), "vrf must be str" - assert isinstance(timers_dict, dict), "timers_dict must be dict" - assert auto_sys != 0, "auto_sys must not be 0" - assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" - timeout = Timeout(max_time, check_interval) - while timeout.iterate(): - if auto_sys and timers_dict: - try: - response = device.parse( - f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp interfaces detail" - ) - except SchemaEmptyParserError: - timeout.sleep() - continue - inter_timers = {} - if (vrf not in response.q.get_values("vrf")) or ( - str(auto_sys) not in response.q.get_values("eigrp_instance") - ): - log.error( - f"Sorry, no data for the provided for 'auto_sys = {auto_sys}' and/or 'vrf = {vrf}'" - ) - else: - interfaces = ( - response.q.contains(vrf) - .contains_key_value("eigrp_instance", str(auto_sys)) - .contains(ip) - .get_values("interface") - ) - for interface in interfaces: - hello_interval = { - "hello_interval": ( - response.q.contains(interface).get_values("hello_interval") - )[0] - } - hold_time = { - "hold_time": ( - response.q.contains(interface).get_values("hold_time") - )[0] - } - inter_timers[interface] = [hello_interval, hold_time] - return set(timers_dict).issubset(inter_timers) - log.error( - f"Please, provide a valid format for auto_sys, timers_dict, vrf and/or ip" - ) - continue From a94f36db5e6bad5b8f06ab2afeab848ceea6b463 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Thu, 9 May 2024 17:55:12 +0100 Subject: [PATCH 26/39] Add files via upload New verify.py --- .../genie/libs/sdk/apis/iosxe/eigrp/verify.py | 249 ++++++++++++++++++ 1 file changed, 249 insertions(+) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py new file mode 100644 index 000000000..4f30fc769 --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py @@ -0,0 +1,249 @@ +from genie.utils.timeout import Timeout +import logging +import os +from genie.metaparser.util.exceptions import SchemaEmptyParserError + +log = logging.getLogger(__name__) + + +def verify_eigrp_interfaces( + device, + vrf="default", + AS_N=None, + interfaces_list=None, + ip="ipv4", + max_time=60, + check_interval=10, +): + """Verify active EIGRP interfaces for ipv4 (Default) or ipv6 for AS and VRF + Args: + device (obj): Device object + vrf = "default" (str): Name of the vrf by default set to "default" + AS_N = None (int): Autonomous System + interfaces_list = None (list): List of active EIGRP interfaces to check + ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" + max_time (`int`): Max time, default: 30 + check_interval (`int`): Check interval, default: 10 + + Returns: + True + False + """ + assert isinstance(AS_N, int), "AS_N must be int" + assert isinstance(vrf, str), "vrf must be str" + assert isinstance( + interfaces_list, list + ), "interfaces_list must be list of interfaces" + assert AS_N != 0, "AS_N must not be 0" + assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" + timeout = Timeout(max_time, check_interval) + while timeout.iterate(): + if AS_N and interfaces_list: + try: + response = device.parse( + f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp interfaces" + ) + except SchemaEmptyParserError: + timeout.sleep() + continue + interfaces = [] + if (vrf not in response.q.get_values("vrf")) or ( + str(AS_N) not in response.q.get_values("eigrp_instance") + ): + log.error( + f"Sorry,no data for the provided 'AS = {AS_N}' and/or 'vrf = {vrf}' !" + ) + else: + interfaces = ( + response.q.contains(vrf) + .contains_key_value("eigrp_instance", str(AS_N)) + .contains(ip) + .get_values("interface") + ) + return set(interfaces_list).issubset(interfaces) + log.error( + f"Please, provide a valid format for AS, interfaces_list, ip and/or vrf" + ) + continue + + +def verify_eigrp_neighbors( + device, + neighbors=None, + vrf="default", + AS_N=None, + ip="ipv4", + max_time=60, + check_interval=10, +): + """Verify active EIGRP neighbors for ipv4 (Default) and ipv6 for AS and VRF + Args: + device (obj): Device object + neighbors = None (list): Active EIGRP neighbors to check + vrf = "default" (str) : Name of the vrf + AS_N = None (int) : Autonomous System + ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" + max_time (`int`): Max time, default: 30 + check_interval (`int`): Check interval, default: 10 + + Returns: + True + False + """ + assert isinstance(AS_N, int), "AS_N must be int" + assert isinstance(vrf, str), "vrf must be str" + assert isinstance(neighbors, list), "neighbors must be list of interfaces" + assert AS_N != 0, "AS_N must not be 0" + assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" + timeout = Timeout(max_time, check_interval) + while timeout.iterate(): + if AS_N and neighbors: + try: + response = device.parse( + f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp neighbors" + ) + except SchemaEmptyParserError: + timeout.sleep() + continue + eigrp_neighbors = [] + if (vrf not in response.q.get_values("vrf")) or ( + str(AS_N) not in response.q.get_values("eigrp_instance") + ): + log.error( + f"Sorry, no data for the provided 'AS = {AS_N}' and/or 'vrf = {vrf}' !" + ) + else: + eigrp_neighbors = ( + response.q.contains_key_value("eigrp_instance", str(AS_N)) + .contains(vrf) + .contains(ip) + .get_values("eigrp_nbr") + ) + return set(neighbors).issubset(eigrp_neighbors) + log.error(f"Please, provide a valid format for AS, Neighbors, ip and/or vrf") + continue + +def verify_eigrp_router_id( + device, + router_id=None, + vrf="default", + auto_sys=None, + ip="ipv4", + max_time=60, + check_interval=10, +): + """verify EIGRP IDs for a given vrf and auto_sys active instance for ipv4 or ipv6 + Args: + device (obj): Device object + router_id = None (list): List of router ID to check + vrf = "default" (str): Name of the vrf by default set to "default" + auto_sys = None (int) : Autonomous System + ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" + max_time (`int`): Max time, default: 30 + check_interval (`int`): Check interval, default: 10 + + Returns: + True + False + """ + assert isinstance(auto_sys, int), "auto_sys must be int" + assert isinstance(vrf, str), "vrf must be str" + assert isinstance(router_id, list), "router_id must be list of router IDs" + assert auto_sys != 0, "auto_sys must not be 0" + assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" + timeout = Timeout(max_time, check_interval) + while timeout.iterate(): + if auto_sys and router_id: + try: + response = device.parse( + f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp topology" + ) + except SchemaEmptyParserError: + timeout.sleep() + continue + eigrp_id = [] + if (vrf not in response.q.get_values("vrf")) or ( + str(auto_sys) not in response.q.get_values("eigrp_instance") + ): + log.error( + f"Sorry, no data for the provided for 'auto_sys = {auto_sys}' and/or 'vrf = {vrf}'" + ) + else: + eigrp_id = ( + response.q.contains_key_value("eigrp_instance", str(auto_sys)) + .contains(vrf) + .contains((ip[0:2]).upper() + ip[2:]) + .get_values("eigrp_id") + ) + return set(router_id).issubset(eigrp_id) + log.error(f"Please, provid a valid format for auto_sys, router_id, vrf and/or ip") + continue + +def verify_eigrp_interfaces_timers( + device, + timers_dict=None, + vrf="default", + auto_sys=None, + ip="ipv4", + max_time=60, + check_interval=10, +): + """Verify hello interval and hold time of interfaces for a given vrf and active auto_sys for ipv4 or ipv6 + Args: + device (obj): Device object + timers_dict (dict): dict to verify containing interfaces with their hello interval and hold time + # ex.) timers_dict = {'FastEthernet0/0': [{'hello_interval': 5}, {'hold_time': 15}]} + vrf (str) : Name of the vrf by default set to "default" + auto_sys (int) : Autonomous System + ip = "ipv4" (str): Protocol ip, default: "ipv4" to change to "ipv6" + max_time (`int`): Max time, default: 30 + check_interval (`int`): Check interval, default: 10 + Returns: + result (bool): Verified result + """ + assert isinstance(auto_sys, int), "auto_sys must be int" + assert isinstance(vrf, str), "vrf must be str" + assert isinstance(timers_dict, dict), "timers_dict must be dict" + assert auto_sys != 0, "auto_sys must not be 0" + assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" + timeout = Timeout(max_time, check_interval) + while timeout.iterate(): + if auto_sys and timers_dict: + try: + response = device.parse( + f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp interfaces detail" + ) + except SchemaEmptyParserError: + timeout.sleep() + continue + inter_timers = {} + if (vrf not in response.q.get_values("vrf")) or ( + str(auto_sys) not in response.q.get_values("eigrp_instance") + ): + log.error( + f"Sorry, no data for the provided for 'auto_sys = {auto_sys}' and/or 'vrf = {vrf}'" + ) + else: + interfaces = ( + response.q.contains(vrf) + .contains_key_value("eigrp_instance", str(auto_sys)) + .contains(ip) + .get_values("interface") + ) + for interface in interfaces: + hello_interval = { + "hello_interval": ( + response.q.contains(interface).get_values("hello_interval") + )[0] + } + hold_time = { + "hold_time": ( + response.q.contains(interface).get_values("hold_time") + )[0] + } + inter_timers[interface] = [hello_interval, hold_time] + return set(timers_dict).issubset(inter_timers) + log.error( + f"Please, provide a valid format for auto_sys, timers_dict, vrf and/or ip" + ) + continue From f349d8baeff072586a16eeb8c24a9d2ed7d5951f Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Thu, 9 May 2024 18:05:05 +0100 Subject: [PATCH 27/39] Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py --- .../genie/libs/sdk/apis/iosxe/eigrp/verify.py | 249 ------------------ 1 file changed, 249 deletions(-) delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py deleted file mode 100644 index 4f30fc769..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py +++ /dev/null @@ -1,249 +0,0 @@ -from genie.utils.timeout import Timeout -import logging -import os -from genie.metaparser.util.exceptions import SchemaEmptyParserError - -log = logging.getLogger(__name__) - - -def verify_eigrp_interfaces( - device, - vrf="default", - AS_N=None, - interfaces_list=None, - ip="ipv4", - max_time=60, - check_interval=10, -): - """Verify active EIGRP interfaces for ipv4 (Default) or ipv6 for AS and VRF - Args: - device (obj): Device object - vrf = "default" (str): Name of the vrf by default set to "default" - AS_N = None (int): Autonomous System - interfaces_list = None (list): List of active EIGRP interfaces to check - ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" - max_time (`int`): Max time, default: 30 - check_interval (`int`): Check interval, default: 10 - - Returns: - True - False - """ - assert isinstance(AS_N, int), "AS_N must be int" - assert isinstance(vrf, str), "vrf must be str" - assert isinstance( - interfaces_list, list - ), "interfaces_list must be list of interfaces" - assert AS_N != 0, "AS_N must not be 0" - assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" - timeout = Timeout(max_time, check_interval) - while timeout.iterate(): - if AS_N and interfaces_list: - try: - response = device.parse( - f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp interfaces" - ) - except SchemaEmptyParserError: - timeout.sleep() - continue - interfaces = [] - if (vrf not in response.q.get_values("vrf")) or ( - str(AS_N) not in response.q.get_values("eigrp_instance") - ): - log.error( - f"Sorry,no data for the provided 'AS = {AS_N}' and/or 'vrf = {vrf}' !" - ) - else: - interfaces = ( - response.q.contains(vrf) - .contains_key_value("eigrp_instance", str(AS_N)) - .contains(ip) - .get_values("interface") - ) - return set(interfaces_list).issubset(interfaces) - log.error( - f"Please, provide a valid format for AS, interfaces_list, ip and/or vrf" - ) - continue - - -def verify_eigrp_neighbors( - device, - neighbors=None, - vrf="default", - AS_N=None, - ip="ipv4", - max_time=60, - check_interval=10, -): - """Verify active EIGRP neighbors for ipv4 (Default) and ipv6 for AS and VRF - Args: - device (obj): Device object - neighbors = None (list): Active EIGRP neighbors to check - vrf = "default" (str) : Name of the vrf - AS_N = None (int) : Autonomous System - ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" - max_time (`int`): Max time, default: 30 - check_interval (`int`): Check interval, default: 10 - - Returns: - True - False - """ - assert isinstance(AS_N, int), "AS_N must be int" - assert isinstance(vrf, str), "vrf must be str" - assert isinstance(neighbors, list), "neighbors must be list of interfaces" - assert AS_N != 0, "AS_N must not be 0" - assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" - timeout = Timeout(max_time, check_interval) - while timeout.iterate(): - if AS_N and neighbors: - try: - response = device.parse( - f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp neighbors" - ) - except SchemaEmptyParserError: - timeout.sleep() - continue - eigrp_neighbors = [] - if (vrf not in response.q.get_values("vrf")) or ( - str(AS_N) not in response.q.get_values("eigrp_instance") - ): - log.error( - f"Sorry, no data for the provided 'AS = {AS_N}' and/or 'vrf = {vrf}' !" - ) - else: - eigrp_neighbors = ( - response.q.contains_key_value("eigrp_instance", str(AS_N)) - .contains(vrf) - .contains(ip) - .get_values("eigrp_nbr") - ) - return set(neighbors).issubset(eigrp_neighbors) - log.error(f"Please, provide a valid format for AS, Neighbors, ip and/or vrf") - continue - -def verify_eigrp_router_id( - device, - router_id=None, - vrf="default", - auto_sys=None, - ip="ipv4", - max_time=60, - check_interval=10, -): - """verify EIGRP IDs for a given vrf and auto_sys active instance for ipv4 or ipv6 - Args: - device (obj): Device object - router_id = None (list): List of router ID to check - vrf = "default" (str): Name of the vrf by default set to "default" - auto_sys = None (int) : Autonomous System - ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" - max_time (`int`): Max time, default: 30 - check_interval (`int`): Check interval, default: 10 - - Returns: - True - False - """ - assert isinstance(auto_sys, int), "auto_sys must be int" - assert isinstance(vrf, str), "vrf must be str" - assert isinstance(router_id, list), "router_id must be list of router IDs" - assert auto_sys != 0, "auto_sys must not be 0" - assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" - timeout = Timeout(max_time, check_interval) - while timeout.iterate(): - if auto_sys and router_id: - try: - response = device.parse( - f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp topology" - ) - except SchemaEmptyParserError: - timeout.sleep() - continue - eigrp_id = [] - if (vrf not in response.q.get_values("vrf")) or ( - str(auto_sys) not in response.q.get_values("eigrp_instance") - ): - log.error( - f"Sorry, no data for the provided for 'auto_sys = {auto_sys}' and/or 'vrf = {vrf}'" - ) - else: - eigrp_id = ( - response.q.contains_key_value("eigrp_instance", str(auto_sys)) - .contains(vrf) - .contains((ip[0:2]).upper() + ip[2:]) - .get_values("eigrp_id") - ) - return set(router_id).issubset(eigrp_id) - log.error(f"Please, provid a valid format for auto_sys, router_id, vrf and/or ip") - continue - -def verify_eigrp_interfaces_timers( - device, - timers_dict=None, - vrf="default", - auto_sys=None, - ip="ipv4", - max_time=60, - check_interval=10, -): - """Verify hello interval and hold time of interfaces for a given vrf and active auto_sys for ipv4 or ipv6 - Args: - device (obj): Device object - timers_dict (dict): dict to verify containing interfaces with their hello interval and hold time - # ex.) timers_dict = {'FastEthernet0/0': [{'hello_interval': 5}, {'hold_time': 15}]} - vrf (str) : Name of the vrf by default set to "default" - auto_sys (int) : Autonomous System - ip = "ipv4" (str): Protocol ip, default: "ipv4" to change to "ipv6" - max_time (`int`): Max time, default: 30 - check_interval (`int`): Check interval, default: 10 - Returns: - result (bool): Verified result - """ - assert isinstance(auto_sys, int), "auto_sys must be int" - assert isinstance(vrf, str), "vrf must be str" - assert isinstance(timers_dict, dict), "timers_dict must be dict" - assert auto_sys != 0, "auto_sys must not be 0" - assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" - timeout = Timeout(max_time, check_interval) - while timeout.iterate(): - if auto_sys and timers_dict: - try: - response = device.parse( - f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp interfaces detail" - ) - except SchemaEmptyParserError: - timeout.sleep() - continue - inter_timers = {} - if (vrf not in response.q.get_values("vrf")) or ( - str(auto_sys) not in response.q.get_values("eigrp_instance") - ): - log.error( - f"Sorry, no data for the provided for 'auto_sys = {auto_sys}' and/or 'vrf = {vrf}'" - ) - else: - interfaces = ( - response.q.contains(vrf) - .contains_key_value("eigrp_instance", str(auto_sys)) - .contains(ip) - .get_values("interface") - ) - for interface in interfaces: - hello_interval = { - "hello_interval": ( - response.q.contains(interface).get_values("hello_interval") - )[0] - } - hold_time = { - "hold_time": ( - response.q.contains(interface).get_values("hold_time") - )[0] - } - inter_timers[interface] = [hello_interval, hold_time] - return set(timers_dict).issubset(inter_timers) - log.error( - f"Please, provide a valid format for auto_sys, timers_dict, vrf and/or ip" - ) - continue From 834e94f29fa32b76feb2f30bb38a6e29c9104298 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Thu, 9 May 2024 18:05:35 +0100 Subject: [PATCH 28/39] Add files via upload New verify.py --- .../genie/libs/sdk/apis/iosxe/eigrp/verify.py | 249 ++++++++++++++++++ 1 file changed, 249 insertions(+) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py new file mode 100644 index 000000000..4f30fc769 --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py @@ -0,0 +1,249 @@ +from genie.utils.timeout import Timeout +import logging +import os +from genie.metaparser.util.exceptions import SchemaEmptyParserError + +log = logging.getLogger(__name__) + + +def verify_eigrp_interfaces( + device, + vrf="default", + AS_N=None, + interfaces_list=None, + ip="ipv4", + max_time=60, + check_interval=10, +): + """Verify active EIGRP interfaces for ipv4 (Default) or ipv6 for AS and VRF + Args: + device (obj): Device object + vrf = "default" (str): Name of the vrf by default set to "default" + AS_N = None (int): Autonomous System + interfaces_list = None (list): List of active EIGRP interfaces to check + ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" + max_time (`int`): Max time, default: 30 + check_interval (`int`): Check interval, default: 10 + + Returns: + True + False + """ + assert isinstance(AS_N, int), "AS_N must be int" + assert isinstance(vrf, str), "vrf must be str" + assert isinstance( + interfaces_list, list + ), "interfaces_list must be list of interfaces" + assert AS_N != 0, "AS_N must not be 0" + assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" + timeout = Timeout(max_time, check_interval) + while timeout.iterate(): + if AS_N and interfaces_list: + try: + response = device.parse( + f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp interfaces" + ) + except SchemaEmptyParserError: + timeout.sleep() + continue + interfaces = [] + if (vrf not in response.q.get_values("vrf")) or ( + str(AS_N) not in response.q.get_values("eigrp_instance") + ): + log.error( + f"Sorry,no data for the provided 'AS = {AS_N}' and/or 'vrf = {vrf}' !" + ) + else: + interfaces = ( + response.q.contains(vrf) + .contains_key_value("eigrp_instance", str(AS_N)) + .contains(ip) + .get_values("interface") + ) + return set(interfaces_list).issubset(interfaces) + log.error( + f"Please, provide a valid format for AS, interfaces_list, ip and/or vrf" + ) + continue + + +def verify_eigrp_neighbors( + device, + neighbors=None, + vrf="default", + AS_N=None, + ip="ipv4", + max_time=60, + check_interval=10, +): + """Verify active EIGRP neighbors for ipv4 (Default) and ipv6 for AS and VRF + Args: + device (obj): Device object + neighbors = None (list): Active EIGRP neighbors to check + vrf = "default" (str) : Name of the vrf + AS_N = None (int) : Autonomous System + ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" + max_time (`int`): Max time, default: 30 + check_interval (`int`): Check interval, default: 10 + + Returns: + True + False + """ + assert isinstance(AS_N, int), "AS_N must be int" + assert isinstance(vrf, str), "vrf must be str" + assert isinstance(neighbors, list), "neighbors must be list of interfaces" + assert AS_N != 0, "AS_N must not be 0" + assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" + timeout = Timeout(max_time, check_interval) + while timeout.iterate(): + if AS_N and neighbors: + try: + response = device.parse( + f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp neighbors" + ) + except SchemaEmptyParserError: + timeout.sleep() + continue + eigrp_neighbors = [] + if (vrf not in response.q.get_values("vrf")) or ( + str(AS_N) not in response.q.get_values("eigrp_instance") + ): + log.error( + f"Sorry, no data for the provided 'AS = {AS_N}' and/or 'vrf = {vrf}' !" + ) + else: + eigrp_neighbors = ( + response.q.contains_key_value("eigrp_instance", str(AS_N)) + .contains(vrf) + .contains(ip) + .get_values("eigrp_nbr") + ) + return set(neighbors).issubset(eigrp_neighbors) + log.error(f"Please, provide a valid format for AS, Neighbors, ip and/or vrf") + continue + +def verify_eigrp_router_id( + device, + router_id=None, + vrf="default", + auto_sys=None, + ip="ipv4", + max_time=60, + check_interval=10, +): + """verify EIGRP IDs for a given vrf and auto_sys active instance for ipv4 or ipv6 + Args: + device (obj): Device object + router_id = None (list): List of router ID to check + vrf = "default" (str): Name of the vrf by default set to "default" + auto_sys = None (int) : Autonomous System + ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" + max_time (`int`): Max time, default: 30 + check_interval (`int`): Check interval, default: 10 + + Returns: + True + False + """ + assert isinstance(auto_sys, int), "auto_sys must be int" + assert isinstance(vrf, str), "vrf must be str" + assert isinstance(router_id, list), "router_id must be list of router IDs" + assert auto_sys != 0, "auto_sys must not be 0" + assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" + timeout = Timeout(max_time, check_interval) + while timeout.iterate(): + if auto_sys and router_id: + try: + response = device.parse( + f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp topology" + ) + except SchemaEmptyParserError: + timeout.sleep() + continue + eigrp_id = [] + if (vrf not in response.q.get_values("vrf")) or ( + str(auto_sys) not in response.q.get_values("eigrp_instance") + ): + log.error( + f"Sorry, no data for the provided for 'auto_sys = {auto_sys}' and/or 'vrf = {vrf}'" + ) + else: + eigrp_id = ( + response.q.contains_key_value("eigrp_instance", str(auto_sys)) + .contains(vrf) + .contains((ip[0:2]).upper() + ip[2:]) + .get_values("eigrp_id") + ) + return set(router_id).issubset(eigrp_id) + log.error(f"Please, provid a valid format for auto_sys, router_id, vrf and/or ip") + continue + +def verify_eigrp_interfaces_timers( + device, + timers_dict=None, + vrf="default", + auto_sys=None, + ip="ipv4", + max_time=60, + check_interval=10, +): + """Verify hello interval and hold time of interfaces for a given vrf and active auto_sys for ipv4 or ipv6 + Args: + device (obj): Device object + timers_dict (dict): dict to verify containing interfaces with their hello interval and hold time + # ex.) timers_dict = {'FastEthernet0/0': [{'hello_interval': 5}, {'hold_time': 15}]} + vrf (str) : Name of the vrf by default set to "default" + auto_sys (int) : Autonomous System + ip = "ipv4" (str): Protocol ip, default: "ipv4" to change to "ipv6" + max_time (`int`): Max time, default: 30 + check_interval (`int`): Check interval, default: 10 + Returns: + result (bool): Verified result + """ + assert isinstance(auto_sys, int), "auto_sys must be int" + assert isinstance(vrf, str), "vrf must be str" + assert isinstance(timers_dict, dict), "timers_dict must be dict" + assert auto_sys != 0, "auto_sys must not be 0" + assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" + timeout = Timeout(max_time, check_interval) + while timeout.iterate(): + if auto_sys and timers_dict: + try: + response = device.parse( + f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp interfaces detail" + ) + except SchemaEmptyParserError: + timeout.sleep() + continue + inter_timers = {} + if (vrf not in response.q.get_values("vrf")) or ( + str(auto_sys) not in response.q.get_values("eigrp_instance") + ): + log.error( + f"Sorry, no data for the provided for 'auto_sys = {auto_sys}' and/or 'vrf = {vrf}'" + ) + else: + interfaces = ( + response.q.contains(vrf) + .contains_key_value("eigrp_instance", str(auto_sys)) + .contains(ip) + .get_values("interface") + ) + for interface in interfaces: + hello_interval = { + "hello_interval": ( + response.q.contains(interface).get_values("hello_interval") + )[0] + } + hold_time = { + "hold_time": ( + response.q.contains(interface).get_values("hold_time") + )[0] + } + inter_timers[interface] = [hello_interval, hold_time] + return set(timers_dict).issubset(inter_timers) + log.error( + f"Please, provide a valid format for auto_sys, timers_dict, vrf and/or ip" + ) + continue From 2220abeb46113f0f89105107f0cef3c5838884b5 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Thu, 9 May 2024 21:28:51 +0100 Subject: [PATCH 29/39] Update verify.py --- pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py index 4f30fc769..fb553afd8 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py @@ -247,3 +247,4 @@ def verify_eigrp_interfaces_timers( f"Please, provide a valid format for auto_sys, timers_dict, vrf and/or ip" ) continue + From cfe9f1bc547990c919c462287cd4b9e953f305aa Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Fri, 10 May 2024 08:15:35 +0100 Subject: [PATCH 30/39] Update verify.py From 0fa631a3366b67b28da5a2a38771448ae1b48772 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Sun, 12 May 2024 21:38:56 +0100 Subject: [PATCH 31/39] Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe directory --- .../mock_data/iosxe/mock_data.yaml | 58 ------------------- 1 file changed, 58 deletions(-) delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 105458fab..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,58 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - prompt: R1(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: R1(config-line)# -connect: - commands: - ? '' - : new_state: execute - preface: 'Trying mock_device ... - - Connected to mock_device. - - Escape character is ''^]''.' - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show ip eigrp interfaces detail: - response: - - "EIGRP-IPv4 Interfaces for AS(1)\r\n Xmit Queue\ - \ PeerQ Mean Pacing Time Multicast Pending\r\nInterface \ - \ Peers Un/Reliable Un/Reliable SRTT Un/Reliable Flow Timer\ - \ Routes\r\nFa0/0 1 0/0 0/0 32\ - \ 0/0 50 0\r\n Hello-interval is 5, Hold-time is\ - \ 15\r\n Split-horizon is enabled\r\n Next xmit serial \r\n Packetized\ - \ sent/expedited: 1/0\r\n Hello's sent/expedited: 303/2\r\n Un/reliable\ - \ mcasts: 0/1 Un/reliable ucasts: 1/2\r\n Mcast exceptions: 0 CR packets:\ - \ 0 ACKs suppressed: 0\r\n Retransmissions sent: 1 Out-of-sequence rcvd:\ - \ 1\r\n Topology-ids on interface - 0 \r\n Authentication mode is not set\r\ - \nEIGRP-IPv4 Interfaces for AS(2)\r\n Xmit Queue\ - \ PeerQ Mean Pacing Time Multicast Pending\r\nInterface \ - \ Peers Un/Reliable Un/Reliable SRTT Un/Reliable Flow Timer\ - \ Routes\r\nFa1/0 0 0/0 0/0 0\ - \ 0/0 0 0\r\n Hello-interval is 5, Hold-time is\ - \ 15\r\n Split-horizon is enabled\r\n Next xmit serial \r\n Packetized\ - \ sent/expedited: 0/0\r\n Hello's sent/expedited: 304/1\r\n Un/reliable\ - \ mcasts: 0/0 Un/reliable ucasts: 0/0\r\n Mcast exceptions: 0 CR packets:\ - \ 0 ACKs suppressed: 0\r\n Retransmissions sent: 0 Out-of-sequence rcvd:\ - \ 0\r\n Topology-ids on interface - 0 \r\n Authentication mode is not set" - response_type: circular - show version: '' - show version | include operating mode: '' - term length 0: '' - term width 0: '' - prompt: R1# From f1ae334ce07344ace1c30fbc4e55a6520c6dffd3 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Sun, 12 May 2024 21:39:53 +0100 Subject: [PATCH 32/39] Create test --- .../verify/verify_eigrp_interfaces_timers/mock_data/iosxe/test | 1 + 1 file changed, 1 insertion(+) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/test diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/test b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/test new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/test @@ -0,0 +1 @@ + From b5525a403ad34f4db5f2141a5a74c10914c5090f Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Sun, 12 May 2024 21:40:44 +0100 Subject: [PATCH 33/39] Add files via upload New mock_data --- .../mock_data/iosxe/mock_data.yaml | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml new file mode 100644 index 000000000..105458fab --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml @@ -0,0 +1,58 @@ +configure: + commands: + end: + new_state: execute + line console 0: + new_state: configure_line + no logging console: '' + prompt: R1(config)# +configure_line: + commands: + end: + new_state: execute + exec-timeout 0: '' + prompt: R1(config-line)# +connect: + commands: + ? '' + : new_state: execute + preface: 'Trying mock_device ... + + Connected to mock_device. + + Escape character is ''^]''.' + prompt: '' +execute: + commands: + config term: + new_state: configure + config-transaction: + new_state: configure + show ip eigrp interfaces detail: + response: + - "EIGRP-IPv4 Interfaces for AS(1)\r\n Xmit Queue\ + \ PeerQ Mean Pacing Time Multicast Pending\r\nInterface \ + \ Peers Un/Reliable Un/Reliable SRTT Un/Reliable Flow Timer\ + \ Routes\r\nFa0/0 1 0/0 0/0 32\ + \ 0/0 50 0\r\n Hello-interval is 5, Hold-time is\ + \ 15\r\n Split-horizon is enabled\r\n Next xmit serial \r\n Packetized\ + \ sent/expedited: 1/0\r\n Hello's sent/expedited: 303/2\r\n Un/reliable\ + \ mcasts: 0/1 Un/reliable ucasts: 1/2\r\n Mcast exceptions: 0 CR packets:\ + \ 0 ACKs suppressed: 0\r\n Retransmissions sent: 1 Out-of-sequence rcvd:\ + \ 1\r\n Topology-ids on interface - 0 \r\n Authentication mode is not set\r\ + \nEIGRP-IPv4 Interfaces for AS(2)\r\n Xmit Queue\ + \ PeerQ Mean Pacing Time Multicast Pending\r\nInterface \ + \ Peers Un/Reliable Un/Reliable SRTT Un/Reliable Flow Timer\ + \ Routes\r\nFa1/0 0 0/0 0/0 0\ + \ 0/0 0 0\r\n Hello-interval is 5, Hold-time is\ + \ 15\r\n Split-horizon is enabled\r\n Next xmit serial \r\n Packetized\ + \ sent/expedited: 0/0\r\n Hello's sent/expedited: 304/1\r\n Un/reliable\ + \ mcasts: 0/0 Un/reliable ucasts: 0/0\r\n Mcast exceptions: 0 CR packets:\ + \ 0 ACKs suppressed: 0\r\n Retransmissions sent: 0 Out-of-sequence rcvd:\ + \ 0\r\n Topology-ids on interface - 0 \r\n Authentication mode is not set" + response_type: circular + show version: '' + show version | include operating mode: '' + term length 0: '' + term width 0: '' + prompt: R1# From c7c3402e87f8871273f1645e552a124efea782c9 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Sun, 12 May 2024 21:41:40 +0100 Subject: [PATCH 34/39] Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/test --- .../verify/verify_eigrp_interfaces_timers/mock_data/iosxe/test | 1 - 1 file changed, 1 deletion(-) delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/test diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/test b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/test deleted file mode 100644 index 8b1378917..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/test +++ /dev/null @@ -1 +0,0 @@ - From cdd0cc9ff25f9d4a6098bd842abb083252b34fd9 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Sun, 12 May 2024 21:42:25 +0100 Subject: [PATCH 35/39] Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py --- .../genie/libs/sdk/apis/iosxe/eigrp/verify.py | 250 ------------------ 1 file changed, 250 deletions(-) delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py deleted file mode 100644 index fb553afd8..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py +++ /dev/null @@ -1,250 +0,0 @@ -from genie.utils.timeout import Timeout -import logging -import os -from genie.metaparser.util.exceptions import SchemaEmptyParserError - -log = logging.getLogger(__name__) - - -def verify_eigrp_interfaces( - device, - vrf="default", - AS_N=None, - interfaces_list=None, - ip="ipv4", - max_time=60, - check_interval=10, -): - """Verify active EIGRP interfaces for ipv4 (Default) or ipv6 for AS and VRF - Args: - device (obj): Device object - vrf = "default" (str): Name of the vrf by default set to "default" - AS_N = None (int): Autonomous System - interfaces_list = None (list): List of active EIGRP interfaces to check - ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" - max_time (`int`): Max time, default: 30 - check_interval (`int`): Check interval, default: 10 - - Returns: - True - False - """ - assert isinstance(AS_N, int), "AS_N must be int" - assert isinstance(vrf, str), "vrf must be str" - assert isinstance( - interfaces_list, list - ), "interfaces_list must be list of interfaces" - assert AS_N != 0, "AS_N must not be 0" - assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" - timeout = Timeout(max_time, check_interval) - while timeout.iterate(): - if AS_N and interfaces_list: - try: - response = device.parse( - f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp interfaces" - ) - except SchemaEmptyParserError: - timeout.sleep() - continue - interfaces = [] - if (vrf not in response.q.get_values("vrf")) or ( - str(AS_N) not in response.q.get_values("eigrp_instance") - ): - log.error( - f"Sorry,no data for the provided 'AS = {AS_N}' and/or 'vrf = {vrf}' !" - ) - else: - interfaces = ( - response.q.contains(vrf) - .contains_key_value("eigrp_instance", str(AS_N)) - .contains(ip) - .get_values("interface") - ) - return set(interfaces_list).issubset(interfaces) - log.error( - f"Please, provide a valid format for AS, interfaces_list, ip and/or vrf" - ) - continue - - -def verify_eigrp_neighbors( - device, - neighbors=None, - vrf="default", - AS_N=None, - ip="ipv4", - max_time=60, - check_interval=10, -): - """Verify active EIGRP neighbors for ipv4 (Default) and ipv6 for AS and VRF - Args: - device (obj): Device object - neighbors = None (list): Active EIGRP neighbors to check - vrf = "default" (str) : Name of the vrf - AS_N = None (int) : Autonomous System - ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" - max_time (`int`): Max time, default: 30 - check_interval (`int`): Check interval, default: 10 - - Returns: - True - False - """ - assert isinstance(AS_N, int), "AS_N must be int" - assert isinstance(vrf, str), "vrf must be str" - assert isinstance(neighbors, list), "neighbors must be list of interfaces" - assert AS_N != 0, "AS_N must not be 0" - assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" - timeout = Timeout(max_time, check_interval) - while timeout.iterate(): - if AS_N and neighbors: - try: - response = device.parse( - f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp neighbors" - ) - except SchemaEmptyParserError: - timeout.sleep() - continue - eigrp_neighbors = [] - if (vrf not in response.q.get_values("vrf")) or ( - str(AS_N) not in response.q.get_values("eigrp_instance") - ): - log.error( - f"Sorry, no data for the provided 'AS = {AS_N}' and/or 'vrf = {vrf}' !" - ) - else: - eigrp_neighbors = ( - response.q.contains_key_value("eigrp_instance", str(AS_N)) - .contains(vrf) - .contains(ip) - .get_values("eigrp_nbr") - ) - return set(neighbors).issubset(eigrp_neighbors) - log.error(f"Please, provide a valid format for AS, Neighbors, ip and/or vrf") - continue - -def verify_eigrp_router_id( - device, - router_id=None, - vrf="default", - auto_sys=None, - ip="ipv4", - max_time=60, - check_interval=10, -): - """verify EIGRP IDs for a given vrf and auto_sys active instance for ipv4 or ipv6 - Args: - device (obj): Device object - router_id = None (list): List of router ID to check - vrf = "default" (str): Name of the vrf by default set to "default" - auto_sys = None (int) : Autonomous System - ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" - max_time (`int`): Max time, default: 30 - check_interval (`int`): Check interval, default: 10 - - Returns: - True - False - """ - assert isinstance(auto_sys, int), "auto_sys must be int" - assert isinstance(vrf, str), "vrf must be str" - assert isinstance(router_id, list), "router_id must be list of router IDs" - assert auto_sys != 0, "auto_sys must not be 0" - assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" - timeout = Timeout(max_time, check_interval) - while timeout.iterate(): - if auto_sys and router_id: - try: - response = device.parse( - f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp topology" - ) - except SchemaEmptyParserError: - timeout.sleep() - continue - eigrp_id = [] - if (vrf not in response.q.get_values("vrf")) or ( - str(auto_sys) not in response.q.get_values("eigrp_instance") - ): - log.error( - f"Sorry, no data for the provided for 'auto_sys = {auto_sys}' and/or 'vrf = {vrf}'" - ) - else: - eigrp_id = ( - response.q.contains_key_value("eigrp_instance", str(auto_sys)) - .contains(vrf) - .contains((ip[0:2]).upper() + ip[2:]) - .get_values("eigrp_id") - ) - return set(router_id).issubset(eigrp_id) - log.error(f"Please, provid a valid format for auto_sys, router_id, vrf and/or ip") - continue - -def verify_eigrp_interfaces_timers( - device, - timers_dict=None, - vrf="default", - auto_sys=None, - ip="ipv4", - max_time=60, - check_interval=10, -): - """Verify hello interval and hold time of interfaces for a given vrf and active auto_sys for ipv4 or ipv6 - Args: - device (obj): Device object - timers_dict (dict): dict to verify containing interfaces with their hello interval and hold time - # ex.) timers_dict = {'FastEthernet0/0': [{'hello_interval': 5}, {'hold_time': 15}]} - vrf (str) : Name of the vrf by default set to "default" - auto_sys (int) : Autonomous System - ip = "ipv4" (str): Protocol ip, default: "ipv4" to change to "ipv6" - max_time (`int`): Max time, default: 30 - check_interval (`int`): Check interval, default: 10 - Returns: - result (bool): Verified result - """ - assert isinstance(auto_sys, int), "auto_sys must be int" - assert isinstance(vrf, str), "vrf must be str" - assert isinstance(timers_dict, dict), "timers_dict must be dict" - assert auto_sys != 0, "auto_sys must not be 0" - assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" - timeout = Timeout(max_time, check_interval) - while timeout.iterate(): - if auto_sys and timers_dict: - try: - response = device.parse( - f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp interfaces detail" - ) - except SchemaEmptyParserError: - timeout.sleep() - continue - inter_timers = {} - if (vrf not in response.q.get_values("vrf")) or ( - str(auto_sys) not in response.q.get_values("eigrp_instance") - ): - log.error( - f"Sorry, no data for the provided for 'auto_sys = {auto_sys}' and/or 'vrf = {vrf}'" - ) - else: - interfaces = ( - response.q.contains(vrf) - .contains_key_value("eigrp_instance", str(auto_sys)) - .contains(ip) - .get_values("interface") - ) - for interface in interfaces: - hello_interval = { - "hello_interval": ( - response.q.contains(interface).get_values("hello_interval") - )[0] - } - hold_time = { - "hold_time": ( - response.q.contains(interface).get_values("hold_time") - )[0] - } - inter_timers[interface] = [hello_interval, hold_time] - return set(timers_dict).issubset(inter_timers) - log.error( - f"Please, provide a valid format for auto_sys, timers_dict, vrf and/or ip" - ) - continue - From 349e14d7bf13256e9070ed0e8eeb866113a5183f Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Sun, 12 May 2024 21:43:15 +0100 Subject: [PATCH 36/39] Add files via upload New verify.py file --- .../genie/libs/sdk/apis/iosxe/eigrp/verify.py | 249 ++++++++++++++++++ 1 file changed, 249 insertions(+) create mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py new file mode 100644 index 000000000..e995e118f --- /dev/null +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py @@ -0,0 +1,249 @@ +from genie.utils.timeout import Timeout +import logging +import os +from genie.metaparser.util.exceptions import SchemaEmptyParserError + +log = logging.getLogger(__name__) + + +def verify_eigrp_interfaces( + device, + vrf="default", + AS_N=None, + interfaces_list=None, + ip="ipv4", + max_time=60, + check_interval=10, +): + """Verify active EIGRP interfaces for ipv4 (Default) or ipv6 for AS and VRF + Args: + device (obj): Device object + vrf = "default" (str): Name of the vrf by default set to "default" + AS_N = None (int): Autonomous System + interfaces_list = None (list): List of active EIGRP interfaces to check + ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" + max_time (`int`): Max time, default: 30 + check_interval (`int`): Check interval, default: 10 + + Returns: + True + False + """ + assert isinstance(AS_N, int), "AS_N must be int" + assert isinstance(vrf, str), "vrf must be str" + assert isinstance( + interfaces_list, list + ), "interfaces_list must be list of interfaces" + assert AS_N != 0, "AS_N must not be 0" + assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" + timeout = Timeout(max_time, check_interval) + while timeout.iterate(): + if AS_N and interfaces_list: + try: + response = device.parse( + f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp interfaces" + ) + except SchemaEmptyParserError: + timeout.sleep() + continue + interfaces = [] + if (vrf not in response.q.get_values("vrf")) or ( + str(AS_N) not in response.q.get_values("eigrp_instance") + ): + log.error( + f"Sorry,no data for the provided 'AS = {AS_N}' and/or 'vrf = {vrf}' !" + ) + else: + interfaces = ( + response.q.contains(vrf) + .contains_key_value("eigrp_instance", str(AS_N)) + .contains(ip) + .get_values("interface") + ) + return set(interfaces_list).issubset(interfaces) + log.error( + f"Please, provide a valid format for AS, interfaces_list, ip and/or vrf" + ) + continue + + +def verify_eigrp_neighbors( + device, + neighbors=None, + vrf="default", + AS_N=None, + ip="ipv4", + max_time=60, + check_interval=10, +): + """Verify active EIGRP neighbors for ipv4 (Default) and ipv6 for AS and VRF + Args: + device (obj): Device object + neighbors = None (list): Active EIGRP neighbors to check + vrf = "default" (str) : Name of the vrf + AS_N = None (int) : Autonomous System + ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" + max_time (`int`): Max time, default: 30 + check_interval (`int`): Check interval, default: 10 + + Returns: + True + False + """ + assert isinstance(AS_N, int), "AS_N must be int" + assert isinstance(vrf, str), "vrf must be str" + assert isinstance(neighbors, list), "neighbors must be list of interfaces" + assert AS_N != 0, "AS_N must not be 0" + assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" + timeout = Timeout(max_time, check_interval) + while timeout.iterate(): + if AS_N and neighbors: + try: + response = device.parse( + f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp neighbors" + ) + except SchemaEmptyParserError: + timeout.sleep() + continue + eigrp_neighbors = [] + if (vrf not in response.q.get_values("vrf")) or ( + str(AS_N) not in response.q.get_values("eigrp_instance") + ): + log.error( + f"Sorry, no data for the provided 'AS = {AS_N}' and/or 'vrf = {vrf}' !" + ) + else: + eigrp_neighbors = ( + response.q.contains_key_value("eigrp_instance", str(AS_N)) + .contains(vrf) + .contains(ip) + .get_values("eigrp_nbr") + ) + return set(neighbors).issubset(eigrp_neighbors) + log.error(f"Please, provide a valid format for AS, Neighbors, ip and/or vrf") + continue + +def verify_eigrp_router_id( + device, + router_id=None, + vrf="default", + auto_sys=None, + ip="ipv4", + max_time=60, + check_interval=10, +): + """verify EIGRP IDs for a given vrf and auto_sys active instance for ipv4 or ipv6 + Args: + device (obj): Device object + router_id = None (list): List of router ID to check + vrf = "default" (str): Name of the vrf by default set to "default" + auto_sys = None (int) : Autonomous System + ip = "ipv4" (str): Protocol ip set by default to "ipv4" to change to "ipv6" + max_time (`int`): Max time, default: 30 + check_interval (`int`): Check interval, default: 10 + + Returns: + True + False + """ + assert isinstance(auto_sys, int), "auto_sys must be int" + assert isinstance(vrf, str), "vrf must be str" + assert isinstance(router_id, list), "router_id must be list of router IDs" + assert auto_sys != 0, "auto_sys must not be 0" + assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" + timeout = Timeout(max_time, check_interval) + while timeout.iterate(): + if auto_sys and router_id: + try: + response = device.parse( + f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp topology" + ) + except SchemaEmptyParserError: + timeout.sleep() + continue + eigrp_id = [] + if (vrf not in response.q.get_values("vrf")) or ( + str(auto_sys) not in response.q.get_values("eigrp_instance") + ): + log.error( + f"Sorry, no data for the provided for 'auto_sys = {auto_sys}' and/or 'vrf = {vrf}'" + ) + else: + eigrp_id = ( + response.q.contains_key_value("eigrp_instance", str(auto_sys)) + .contains(vrf) + .contains((ip[0:2]).upper() + ip[2:]) + .get_values("eigrp_id") + ) + return set(router_id).issubset(eigrp_id) + log.error(f"Please, provid a valid format for auto_sys, router_id, vrf and/or ip") + continue + +def verify_eigrp_interfaces_timers( + device, + timers_dict=None, + vrf="default", + auto_sys=None, + ip="ipv4", + max_time=60, + check_interval=10, +): + """Verify hello interval and hold time of interfaces for a given vrf and active auto_sys for ipv4 or ipv6 + Args: + device (obj): Device object + timers_dict (dict): dict to verify containing interfaces with their hello interval and hold time + # ex.) timers_dict = {'FastEthernet0/0': [{'hello_interval': 5}, {'hold_time': 15}]} + vrf (str) : Name of the vrf by default set to "default" + auto_sys (int) : Autonomous System + ip = "ipv4" (str): Protocol ip, default: "ipv4" to change to "ipv6" + max_time (`int`): Max time, default: 30 + check_interval (`int`): Check interval, default: 10 + Returns: + result (bool): Verified result + """ + assert isinstance(auto_sys, int), "auto_sys must be int" + assert isinstance(vrf, str), "vrf must be str" + assert isinstance(timers_dict, dict), "timers_dict must be dict" + assert auto_sys != 0, "auto_sys must not be 0" + assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" + timeout = Timeout(max_time, check_interval) + while timeout.iterate(): + if auto_sys and timers_dict: + try: + response = device.parse( + f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp interfaces detail" + ) + except SchemaEmptyParserError: + timeout.sleep() + continue + inter_timers = {} + if (vrf not in response.q.get_values("vrf")) or ( + str(auto_sys) not in response.q.get_values("eigrp_instance") + ): + log.error( + f"Sorry, no data for the provided for 'auto_sys = {auto_sys}' and/or 'vrf = {vrf}'" + ) + else: + interfaces = ( + response.q.contains(vrf) + .contains_key_value("eigrp_instance", str(auto_sys)) + .contains(ip) + .get_values("interface") + ) + for interface in interfaces: + hello_interval = { + "hello_interval": ( + response.q.contains(interface).get_values("hello_interval") + )[0] + } + hold_time = { + "hold_time": ( + response.q.contains(interface).get_values("hold_time") + )[0] + } + inter_timers[interface] = [hello_interval, hold_time] + return set(timers_dict).issubset(inter_timers) + log.error( + f"Please, provide a valid format for auto_sys, timers_dict, vrf and/or ip" + ) + continue \ No newline at end of file From bc7fc380786f3b5e71a18a43c8a649bf770b0c42 Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Mon, 13 May 2024 14:41:20 +0100 Subject: [PATCH 37/39] Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers directory --- .../mock_data/iosxe/mock_data.yaml | 58 ------------------- ...test_api_verify_eigrp_interfaces_timers.py | 35 ----------- 2 files changed, 93 deletions(-) delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml delete mode 100644 pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/test_api_verify_eigrp_interfaces_timers.py diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml deleted file mode 100644 index 105458fab..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/mock_data/iosxe/mock_data.yaml +++ /dev/null @@ -1,58 +0,0 @@ -configure: - commands: - end: - new_state: execute - line console 0: - new_state: configure_line - no logging console: '' - prompt: R1(config)# -configure_line: - commands: - end: - new_state: execute - exec-timeout 0: '' - prompt: R1(config-line)# -connect: - commands: - ? '' - : new_state: execute - preface: 'Trying mock_device ... - - Connected to mock_device. - - Escape character is ''^]''.' - prompt: '' -execute: - commands: - config term: - new_state: configure - config-transaction: - new_state: configure - show ip eigrp interfaces detail: - response: - - "EIGRP-IPv4 Interfaces for AS(1)\r\n Xmit Queue\ - \ PeerQ Mean Pacing Time Multicast Pending\r\nInterface \ - \ Peers Un/Reliable Un/Reliable SRTT Un/Reliable Flow Timer\ - \ Routes\r\nFa0/0 1 0/0 0/0 32\ - \ 0/0 50 0\r\n Hello-interval is 5, Hold-time is\ - \ 15\r\n Split-horizon is enabled\r\n Next xmit serial \r\n Packetized\ - \ sent/expedited: 1/0\r\n Hello's sent/expedited: 303/2\r\n Un/reliable\ - \ mcasts: 0/1 Un/reliable ucasts: 1/2\r\n Mcast exceptions: 0 CR packets:\ - \ 0 ACKs suppressed: 0\r\n Retransmissions sent: 1 Out-of-sequence rcvd:\ - \ 1\r\n Topology-ids on interface - 0 \r\n Authentication mode is not set\r\ - \nEIGRP-IPv4 Interfaces for AS(2)\r\n Xmit Queue\ - \ PeerQ Mean Pacing Time Multicast Pending\r\nInterface \ - \ Peers Un/Reliable Un/Reliable SRTT Un/Reliable Flow Timer\ - \ Routes\r\nFa1/0 0 0/0 0/0 0\ - \ 0/0 0 0\r\n Hello-interval is 5, Hold-time is\ - \ 15\r\n Split-horizon is enabled\r\n Next xmit serial \r\n Packetized\ - \ sent/expedited: 0/0\r\n Hello's sent/expedited: 304/1\r\n Un/reliable\ - \ mcasts: 0/0 Un/reliable ucasts: 0/0\r\n Mcast exceptions: 0 CR packets:\ - \ 0 ACKs suppressed: 0\r\n Retransmissions sent: 0 Out-of-sequence rcvd:\ - \ 0\r\n Topology-ids on interface - 0 \r\n Authentication mode is not set" - response_type: circular - show version: '' - show version | include operating mode: '' - term length 0: '' - term width 0: '' - prompt: R1# diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/test_api_verify_eigrp_interfaces_timers.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/test_api_verify_eigrp_interfaces_timers.py deleted file mode 100644 index 1c45eb39b..000000000 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/verify_eigrp_interfaces_timers/test_api_verify_eigrp_interfaces_timers.py +++ /dev/null @@ -1,35 +0,0 @@ -import os -import unittest -from pyats.topology import loader -from genie.libs.sdk.apis.iosxe.eigrp.verify import verify_eigrp_interfaces_timers - - -class TestVerifyEigrpInterfacesTimers(unittest.TestCase): - - @classmethod - def setUpClass(self): - testbed = f""" - devices: - R1: - connections: - defaults: - class: unicon.Unicon - a: - command: mock_device_cli --os iosxe --mock_data_dir {os.path.dirname(__file__)}/mock_data --state connect - protocol: unknown - os: iosxe - platform: iosxe - type: iosxe - """ - self.testbed = loader.load(testbed) - self.device = self.testbed.devices['R1'] - self.device.connect( - learn_hostname=True, - init_config_commands=[], - init_exec_commands=[] - ) - - def test_verify_eigrp_interfaces_timers(self): - result = verify_eigrp_interfaces_timers(self.device, {'FastEthernet0/0': [{'hello_interval': 5}, {'hold_time': 15}]}, 'default', 1, 'ipv4', 60, 10) - expected_output = True - self.assertEqual(result, expected_output) From 15b066b9349f3e77bcb75cc413ff5aa4cf27cb2d Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Mon, 13 May 2024 14:42:27 +0100 Subject: [PATCH 38/39] Update verify.py --- .../genie/libs/sdk/apis/iosxe/eigrp/verify.py | 69 ------------------- 1 file changed, 69 deletions(-) diff --git a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py index e995e118f..9191b5b46 100644 --- a/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py +++ b/pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py @@ -178,72 +178,3 @@ def verify_eigrp_router_id( return set(router_id).issubset(eigrp_id) log.error(f"Please, provid a valid format for auto_sys, router_id, vrf and/or ip") continue - -def verify_eigrp_interfaces_timers( - device, - timers_dict=None, - vrf="default", - auto_sys=None, - ip="ipv4", - max_time=60, - check_interval=10, -): - """Verify hello interval and hold time of interfaces for a given vrf and active auto_sys for ipv4 or ipv6 - Args: - device (obj): Device object - timers_dict (dict): dict to verify containing interfaces with their hello interval and hold time - # ex.) timers_dict = {'FastEthernet0/0': [{'hello_interval': 5}, {'hold_time': 15}]} - vrf (str) : Name of the vrf by default set to "default" - auto_sys (int) : Autonomous System - ip = "ipv4" (str): Protocol ip, default: "ipv4" to change to "ipv6" - max_time (`int`): Max time, default: 30 - check_interval (`int`): Check interval, default: 10 - Returns: - result (bool): Verified result - """ - assert isinstance(auto_sys, int), "auto_sys must be int" - assert isinstance(vrf, str), "vrf must be str" - assert isinstance(timers_dict, dict), "timers_dict must be dict" - assert auto_sys != 0, "auto_sys must not be 0" - assert ip in ["ipv4", "ipv6"], "ip must be ipv4 or ipv6" - timeout = Timeout(max_time, check_interval) - while timeout.iterate(): - if auto_sys and timers_dict: - try: - response = device.parse( - f"show {'ipv6' if ip!='ipv4' else 'ip'} eigrp interfaces detail" - ) - except SchemaEmptyParserError: - timeout.sleep() - continue - inter_timers = {} - if (vrf not in response.q.get_values("vrf")) or ( - str(auto_sys) not in response.q.get_values("eigrp_instance") - ): - log.error( - f"Sorry, no data for the provided for 'auto_sys = {auto_sys}' and/or 'vrf = {vrf}'" - ) - else: - interfaces = ( - response.q.contains(vrf) - .contains_key_value("eigrp_instance", str(auto_sys)) - .contains(ip) - .get_values("interface") - ) - for interface in interfaces: - hello_interval = { - "hello_interval": ( - response.q.contains(interface).get_values("hello_interval") - )[0] - } - hold_time = { - "hold_time": ( - response.q.contains(interface).get_values("hold_time") - )[0] - } - inter_timers[interface] = [hello_interval, hold_time] - return set(timers_dict).issubset(inter_timers) - log.error( - f"Please, provide a valid format for auto_sys, timers_dict, vrf and/or ip" - ) - continue \ No newline at end of file From eea981e48ee9db9929be4e9797b951c341b583bb Mon Sep 17 00:00:00 2001 From: Mehdi Cherifi <73710391+cherifimehdi@users.noreply.github.com> Date: Mon, 13 May 2024 14:43:01 +0100 Subject: [PATCH 39/39] Delete pkgs/sdk-pkg/changelog/changelog_add_verify_eigrp_interfaces_timers_apis_202419041835.rst --- ...add_verify_eigrp_interfaces_timers_apis_202419041835.rst | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 pkgs/sdk-pkg/changelog/changelog_add_verify_eigrp_interfaces_timers_apis_202419041835.rst diff --git a/pkgs/sdk-pkg/changelog/changelog_add_verify_eigrp_interfaces_timers_apis_202419041835.rst b/pkgs/sdk-pkg/changelog/changelog_add_verify_eigrp_interfaces_timers_apis_202419041835.rst deleted file mode 100644 index de2947695..000000000 --- a/pkgs/sdk-pkg/changelog/changelog_add_verify_eigrp_interfaces_timers_apis_202419041835.rst +++ /dev/null @@ -1,6 +0,0 @@ --------------------------------------------------------------------------------- - New --------------------------------------------------------------------------------- -* IOSXE - * Added verify_eigrp_interfaces_timers to verify.py: - * New API supporting IPv4 and IPv6 to verify EIGRP interfaces timers \ No newline at end of file