Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add verify_eigrp_interfaces_timers API to verify.py ios/iosxe eigrp protocol (my previous contribution) supporting EIGRPv4 and EIGRPv6 for IOS/IOSXE #161

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
07a18de
Create test
cherifimehdi Apr 19, 2024
ea82622
Add files via upload
cherifimehdi Apr 19, 2024
71e6b74
Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/…
cherifimehdi Apr 19, 2024
3d8629b
Add files via upload
cherifimehdi Apr 19, 2024
ad28677
Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py
cherifimehdi Apr 19, 2024
0c3f617
Add files via upload
cherifimehdi Apr 19, 2024
870cde5
Add files via upload
cherifimehdi Apr 19, 2024
3b1c8aa
Update verify.py
cherifimehdi May 9, 2024
d0a3049
Update mock_data.yaml
cherifimehdi May 9, 2024
3392b47
Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/…
cherifimehdi May 9, 2024
d7fb358
Create tst
cherifimehdi May 9, 2024
b23019b
Add files via upload
cherifimehdi May 9, 2024
91d77df
Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/…
cherifimehdi May 9, 2024
9aa5f43
Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py
cherifimehdi May 9, 2024
f269510
Add files via upload
cherifimehdi May 9, 2024
e371ca7
Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/…
cherifimehdi May 9, 2024
e791a69
Create tst
cherifimehdi May 9, 2024
3462971
Add files via upload
cherifimehdi May 9, 2024
ab3a82f
Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/…
cherifimehdi May 9, 2024
a4f1b96
Update pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/…
cherifimehdi May 9, 2024
a84e4c2
Merge branch 'CiscoTestAutomation:master' into master
cherifimehdi May 9, 2024
c7ef175
Update mock_data.yaml
cherifimehdi May 9, 2024
466db60
Update mock_data.yaml
cherifimehdi May 9, 2024
0b461b8
Update pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/…
cherifimehdi May 9, 2024
b9b115c
Update verify.py
cherifimehdi May 9, 2024
84761c9
Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py
cherifimehdi May 9, 2024
a94f36d
Add files via upload
cherifimehdi May 9, 2024
f349d8b
Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py
cherifimehdi May 9, 2024
834e94f
Add files via upload
cherifimehdi May 9, 2024
2220abe
Update verify.py
cherifimehdi May 9, 2024
cfe9f1b
Update verify.py
cherifimehdi May 10, 2024
0fa631a
Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/…
cherifimehdi May 12, 2024
f1ae334
Create test
cherifimehdi May 12, 2024
b5525a4
Add files via upload
cherifimehdi May 12, 2024
c7c3402
Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/…
cherifimehdi May 12, 2024
cdd0cc9
Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py
cherifimehdi May 12, 2024
349e14d
Add files via upload
cherifimehdi May 12, 2024
bc7fc38
Delete pkgs/sdk-pkg/src/genie/libs/sdk/apis/tests/iosxe/eigrp/verify/…
cherifimehdi May 13, 2024
15b066b
Update verify.py
cherifimehdi May 13, 2024
eea981e
Delete pkgs/sdk-pkg/changelog/changelog_add_verify_eigrp_interfaces_t…
cherifimehdi May 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
71 changes: 71 additions & 0 deletions pkgs/sdk-pkg/src/genie/libs/sdk/apis/iosxe/eigrp/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,74 @@ 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:
True
False
cherifimehdi marked this conversation as resolved.
Show resolved Hide resolved
"""
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)
cherifimehdi marked this conversation as resolved.
Show resolved Hide resolved
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
Original file line number Diff line number Diff line change
@@ -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 <none>\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 <none>\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: ''
cherifimehdi marked this conversation as resolved.
Show resolved Hide resolved
term length 0: ''
term width 0: ''
prompt: R1#
Original file line number Diff line number Diff line change
@@ -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)
Loading