fix nxos_igmp_snooping issues (#38566)

* fix nxos_igmp_snooping issue

* shippable error fix
pull/36696/merge
saichint 7 years ago committed by Trishna Guha
parent 0d79268a6d
commit ed42331105

@ -53,6 +53,7 @@ options:
report_supp: report_supp:
description: description:
- Global IGMPv1/IGMPv2 Report Suppression. - Global IGMPv1/IGMPv2 Report Suppression.
type: bool
v3_report_supp: v3_report_supp:
description: description:
- Global IGMPv3 Report Suppression and Proxy Reporting. - Global IGMPv3 Report Suppression and Proxy Reporting.
@ -127,17 +128,6 @@ def get_group_timeout(config):
return value 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): def get_igmp_snooping(module):
command = 'show ip igmp snooping' command = 'show ip igmp snooping'
existing = {} existing = {}
@ -196,6 +186,9 @@ def config_igmp_snooping(delta, existing, default=False):
if default and key == 'group_timeout': if default and key == 'group_timeout':
if existing.get(key): if existing.get(key):
command = 'no ' + CMDS.get(key).format(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: else:
command = CMDS.get(key).format(value) command = CMDS.get(key).format(value)
else: else:

@ -3,14 +3,24 @@
- debug: msg="Using provider={{ connection.transport }}" - debug: msg="Using provider={{ connection.transport }}"
when: ansible_connection == "local" 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: - block:
- 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: true snooping: false
group_timeout: never group_timeout: "{{group_timeout|default(omit)}}"
link_local_grp_supp: true link_local_grp_supp: false
report_supp: true report_supp: false
v3_report_supp: true v3_report_supp: true
state: present state: present
provider: "{{ connection }}" provider: "{{ connection }}"
@ -19,14 +29,33 @@
- assert: &true - assert: &true
that: that:
- "result.changed == true" - "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" - assert: &false
nxos_igmp_snooping: *non-default 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 register: result
- assert: &false - assert: *true
that: when: gt_run
- "result.changed == false"
- 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 - name: Configure igmp snooping with default values
nxos_igmp_snooping: &default nxos_igmp_snooping: &default
@ -36,11 +65,13 @@
- assert: *true - assert: *true
- name: "Check Idempotence - Configure igmp snooping with default values" - block:
nxos_igmp_snooping: *default - name: "Check Idempotence - Configure igmp snooping with default values"
register: result nxos_igmp_snooping: *default
register: result
- assert: *false - assert: *false
when: (imagetag and (imagetag is version_compare('D1', 'ne')))
always: always:
- name: Configure igmp snooping with default values - name: Configure igmp snooping with default values

@ -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_file_copy.py E324
lib/ansible/modules/network/nxos/nxos_gir.py E326 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_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_interface.py E324
lib/ansible/modules/network/nxos/nxos_lldp.py E326 lib/ansible/modules/network/nxos/nxos_lldp.py E326
lib/ansible/modules/network/nxos/nxos_logging.py E325 lib/ansible/modules/network/nxos/nxos_logging.py E325

Loading…
Cancel
Save