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

fix nxos_igmp_snooping issues #38566

Merged
merged 2 commits into from
Apr 11, 2018
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: 4 additions & 11 deletions lib/ansible/modules/network/nxos/nxos_igmp_snooping.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
report_supp:
description:
- Global IGMPv1/IGMPv2 Report Suppression.
type: bool
v3_report_supp:
description:
- Global IGMPv3 Report Suppression and Proxy Reporting.
Expand Down Expand Up @@ -127,17 +128,6 @@ def get_group_timeout(config):
return value


def get_snooping(config):
REGEX = re.compile(r'{0}$'.format('no ip igmp snooping'), re.M)
value = False
try:
if REGEX.search(config):
value = False
except TypeError:
value = True
return value


def get_igmp_snooping(module):
command = 'show ip igmp snooping'
existing = {}
Expand Down Expand Up @@ -196,6 +186,9 @@ def config_igmp_snooping(delta, existing, default=False):
if default and key == 'group_timeout':
if existing.get(key):
command = 'no ' + CMDS.get(key).format(existing.get(key))
elif value == 'default' and key == 'group_timeout':
if existing.get(key):
command = 'no ' + CMDS.get(key).format(existing.get(key))
else:
command = CMDS.get(key).format(value)
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@
- debug: msg="Using provider={{ connection.transport }}"
when: ansible_connection == "local"

- set_fact: gt_run="false"
- set_fact: gt_run="true"
when: not (platform is match("N5K")) and not (platform is match("N35"))

- set_fact: group_timeout="never"
when: not (platform is match("N5K")) and not (platform is match("N35"))

- set_fact: def_group_timeout="default"
when: not (platform is match("N5K")) and not (platform is match("N35"))

- block:

- name: Configure igmp snooping with non-default values
nxos_igmp_snooping: &non-default
snooping: true
group_timeout: never
link_local_grp_supp: true
report_supp: true
snooping: false
group_timeout: "{{group_timeout|default(omit)}}"
link_local_grp_supp: false
report_supp: false
v3_report_supp: true
state: present
provider: "{{ connection }}"
Expand All @@ -19,14 +29,33 @@
- assert: &true
that:
- "result.changed == true"
- block:
- name: "Check Idempotence - Configure igmp snooping with non-default values"
nxos_igmp_snooping: *non-default
register: result

- name: "Check Idempotence - Configure igmp snooping with non-default values"
nxos_igmp_snooping: *non-default
- assert: &false
that:
- "result.changed == false"
when: (imagetag and (imagetag is version_compare('D1', 'ne')))

- name: Configure igmp snooping with default group timeout
nxos_igmp_snooping: &defgt
group_timeout: "{{def_group_timeout|default(omit)}}"
state: present
provider: "{{ connection }}"
register: result

- assert: &false
that:
- "result.changed == false"
- assert: *true
when: gt_run

- block:
- name: "Check Idempotence"
nxos_igmp_snooping: *defgt
register: result

- assert: *false
when: gt_run or (imagetag and (imagetag is version_compare('D1', 'ne')))

- name: Configure igmp snooping with default values
nxos_igmp_snooping: &default
Expand All @@ -36,11 +65,13 @@

- assert: *true

- name: "Check Idempotence - Configure igmp snooping with default values"
nxos_igmp_snooping: *default
register: result
- block:
- name: "Check Idempotence - Configure igmp snooping with default values"
nxos_igmp_snooping: *default
register: result

- assert: *false
- assert: *false
when: (imagetag and (imagetag is version_compare('D1', 'ne')))

always:
- name: Configure igmp snooping with default values
Expand Down
1 change: 0 additions & 1 deletion test/sanity/validate-modules/ignore.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,6 @@ lib/ansible/modules/network/nxos/nxos_evpn_global.py E326
lib/ansible/modules/network/nxos/nxos_file_copy.py E324
lib/ansible/modules/network/nxos/nxos_gir.py E326
lib/ansible/modules/network/nxos/nxos_igmp_interface.py E326
lib/ansible/modules/network/nxos/nxos_igmp_snooping.py E325
lib/ansible/modules/network/nxos/nxos_interface.py E324
lib/ansible/modules/network/nxos/nxos_lldp.py E326
lib/ansible/modules/network/nxos/nxos_logging.py E325
Expand Down