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

nxos_igmp_snooping: group-timeout fails when igmp snooping disabled #53079

Merged
merged 4 commits into from
Mar 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/ansible/modules/network/nxos/nxos_igmp_snooping.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,19 @@ def get_igmp_snooping_defaults():
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():
argument_spec = dict(
snooping=dict(required=False, type='bool'),
Expand Down Expand Up @@ -260,6 +273,8 @@ def main():
if delta:
command = config_igmp_snooping(delta, existing)
if command:
if group_timeout:
igmp_snooping_gt_dependency(command, existing, module)
commands.append(command)
elif state == 'default':
proposed = get_igmp_snooping_defaults()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
- name: Configure igmp snooping with non-default values
nxos_igmp_snooping: &non-default
snooping: false
group_timeout: "{{group_timeout|default(omit)}}"
# group_timeout: n/a when snooping:false
link_local_grp_supp: false
report_supp: false
v3_report_supp: true
Expand All @@ -39,6 +39,38 @@
- "result.changed == false"
when: (imagetag and (imagetag is version_compare('D1', 'ne')))

- block:
chrisvanheuveln marked this conversation as resolved.
Show resolved Hide resolved
- 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
nxos_igmp_snooping: &defgt
group_timeout: "{{def_group_timeout|default(omit)}}"
Expand Down