mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 14:20:22 -07:00
nxos_igmp_snooping: group-timeout fails when igmp snooping disabled (#53079)
* nxos_igmp_snooping: group-timeout fails when igmp snooping disabled group-timeout config will be rejected by the device if `ip igmp snooping` is disabled. * raise a failure for this condition * reorder the command list so that group-timeout is always last * SA fixes * SA fixes * only call gt_dependency if gt
This commit is contained in:
parent
ea0ef3b2e1
commit
8c33ba3ecd
2 changed files with 48 additions and 1 deletions
|
@ -218,6 +218,19 @@ def get_igmp_snooping_defaults():
|
||||||
return default
|
return default
|
||||||
|
|
||||||
|
|
||||||
|
def igmp_snooping_gt_dependency(command, existing, module):
|
||||||
|
# group-timeout will fail if igmp snooping is disabled
|
||||||
|
gt = [i for i in command if i.startswith('ip igmp snooping group-timeout')]
|
||||||
|
if gt:
|
||||||
|
if 'no ip igmp snooping' in command or (existing['snooping'] is False and 'ip igmp snooping' not in command):
|
||||||
|
msg = "group-timeout cannot be enabled or changed when ip igmp snooping is disabled"
|
||||||
|
module.fail_json(msg=msg)
|
||||||
|
else:
|
||||||
|
# ensure that group-timeout command is configured last
|
||||||
|
command.remove(gt[0])
|
||||||
|
command.append(gt[0])
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
snooping=dict(required=False, type='bool'),
|
snooping=dict(required=False, type='bool'),
|
||||||
|
@ -260,6 +273,8 @@ def main():
|
||||||
if delta:
|
if delta:
|
||||||
command = config_igmp_snooping(delta, existing)
|
command = config_igmp_snooping(delta, existing)
|
||||||
if command:
|
if command:
|
||||||
|
if group_timeout:
|
||||||
|
igmp_snooping_gt_dependency(command, existing, module)
|
||||||
commands.append(command)
|
commands.append(command)
|
||||||
elif state == 'default':
|
elif state == 'default':
|
||||||
proposed = get_igmp_snooping_defaults()
|
proposed = get_igmp_snooping_defaults()
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
- name: Configure igmp snooping with non-default values
|
- name: Configure igmp snooping with non-default values
|
||||||
nxos_igmp_snooping: &non-default
|
nxos_igmp_snooping: &non-default
|
||||||
snooping: false
|
snooping: false
|
||||||
group_timeout: "{{group_timeout|default(omit)}}"
|
# group_timeout: n/a when snooping:false
|
||||||
link_local_grp_supp: false
|
link_local_grp_supp: false
|
||||||
report_supp: false
|
report_supp: false
|
||||||
v3_report_supp: true
|
v3_report_supp: true
|
||||||
|
@ -39,6 +39,38 @@
|
||||||
- "result.changed == false"
|
- "result.changed == false"
|
||||||
when: (imagetag and (imagetag is version_compare('D1', 'ne')))
|
when: (imagetag and (imagetag is version_compare('D1', 'ne')))
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: Negative Test config group-timeout when igmp snooping disabled
|
||||||
|
nxos_igmp_snooping:
|
||||||
|
snooping: false
|
||||||
|
group_timeout: "{{group_timeout|default(omit)}}"
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
state: present
|
||||||
|
ignore_errors: yes
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- "result.failed == true"
|
||||||
|
- "result.msg == 'group-timeout cannot be enabled or changed when ip igmp snooping is disabled'"
|
||||||
|
|
||||||
|
- name: Configure group-timeout non-default
|
||||||
|
nxos_igmp_snooping: &non-defgt
|
||||||
|
snooping: true
|
||||||
|
group_timeout: "{{group_timeout|default(omit)}}"
|
||||||
|
provider: "{{ connection }}"
|
||||||
|
state: present
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *true
|
||||||
|
|
||||||
|
- name: "Check Idempotence"
|
||||||
|
nxos_igmp_snooping: *non-defgt
|
||||||
|
register: result
|
||||||
|
|
||||||
|
- assert: *false
|
||||||
|
when: gt_run
|
||||||
|
|
||||||
- name: Configure igmp snooping with default group timeout
|
- name: Configure igmp snooping with default group timeout
|
||||||
nxos_igmp_snooping: &defgt
|
nxos_igmp_snooping: &defgt
|
||||||
group_timeout: "{{def_group_timeout|default(omit)}}"
|
group_timeout: "{{def_group_timeout|default(omit)}}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue