Skip to content

Commit 93ae466

Browse files
authored
Merge branch 'main' into cdp_changes
2 parents 390a0ca + 4964ac7 commit 93ae466

File tree

3 files changed

+54
-8
lines changed

3 files changed

+54
-8
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bugfixes:
2+
- cisco.nxos.nxos_hsrp_interfaces - Fix parsers for preempt and priority

plugins/module_utils/network/nxos/rm_templates/hsrp_interfaces.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,14 @@ def __init__(self, lines=None, module=None):
225225
"name": "preempt",
226226
"getval": re.compile(
227227
r"""
228-
\s*hsrp\s(?P<grp_no>\d+)
229-
\s*preempt\sdelay
230-
(\sminimum\s(?P<minimum>\d+))
231-
(\sreload\s(?P<reload>\d+))
232-
(\ssync\s(?P<sync>\d+))
233-
$""", re.VERBOSE,
228+
^\s*hsrp\s(?P<grp_no>\d+)
229+
\s*preempt
230+
(\sdelay
231+
(\sminimum\s(?P<minimum>\d+))?
232+
(\sreload\s(?P<reload>\d+))?
233+
(\ssync\s(?P<sync>\d+))?
234+
)?
235+
\s*$""", re.VERBOSE,
234236
),
235237
"setval": "preempt delay minimum {{ preempt.minimum|string }}"
236238
"{{ (' reload ' + preempt.reload|string) if preempt.reload is defined else '' }}"
@@ -253,8 +255,7 @@ def __init__(self, lines=None, module=None):
253255
r"""
254256
\s*hsrp\s(?P<grp_no>\d+)
255257
\s*priority\s(?P<priority>\d+)
256-
(\sforwarding-threshold\slower\s(?P<lower>\d+))
257-
(\supper\s(?P<upper>\d+))
258+
(\sforwarding-threshold\slower\s(?P<lower>\d+)\supper\s(?P<upper>\d+))?
258259
$""", re.VERBOSE,
259260
),
260261
"setval": "priority {{ priority.level|string }}"

tests/unit/modules/network/nxos/test_nxos_hsrp_interfaces.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,3 +598,46 @@ def test_nxos_hsrp_interfaces_deprecated_bfd(self):
598598
"no hsrp version 2",
599599
]
600600
self.assertEqual(set(result["commands"]), set(commands))
601+
602+
def test_nxos_hsrp_interfaces_gathered(self):
603+
self.get_config.return_value = dedent(
604+
"""\
605+
interface Vlan1
606+
hsrp 10 preempt delay minimum 10 reload 100 sync 5
607+
hsrp 10 priority 100 forwarding-threshold lower 12 upper 22
608+
hsrp 10 timers msec 456 33
609+
interface Vlan2
610+
hsrp 11 preempt delay minimum 10 sync 5
611+
hsrp 11 priority 100
612+
hsrp 11 timers 456 33
613+
""",
614+
)
615+
set_module_args(
616+
dict(
617+
state="gathered",
618+
),
619+
)
620+
result = self.execute_module(changed=False)
621+
gathered = [
622+
{
623+
"name": "Vlan1",
624+
"standby_options": [
625+
{
626+
"preempt": {"minimum": 10, "reload": 100, "sync": 5},
627+
"priority": {"level": 100, "lower": 12, "upper": 22},
628+
"timer": {"hello_interval": 456, "hold_time": 33, "msec": True},
629+
},
630+
],
631+
},
632+
{
633+
"name": "Vlan2",
634+
"standby_options": [
635+
{
636+
"preempt": {"minimum": 10, "sync": 5},
637+
"priority": {"level": 100},
638+
"timer": {"hello_interval": 456, "hold_time": 33},
639+
},
640+
],
641+
},
642+
]
643+
self.assertEqual(result["gathered"], gathered)

0 commit comments

Comments
 (0)