Skip to content

Commit

Permalink
nxos_snmp_traps: fix 'group: all' for N35 platforms (ansible#55995)
Browse files Browse the repository at this point in the history
* nxos_snmp_traps: fix 'group: all' for N35 platforms

- `group: all` attempts to enable traps for all features defined in the module's `feature_list`

- `N35` platforms do not support `snmp-server enable traps bfd`; so removing `bfd` from the `feature_list` for that platform

- Minor cleanup in `sanity.yaml` test file

* whitespace lint fix
  • Loading branch information
chrisvanheuveln authored and trishnaguha committed May 7, 2019
1 parent d39be3d commit 0e0c2a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
11 changes: 11 additions & 0 deletions lib/ansible/modules/network/nxos/nxos_snmp_traps.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,15 @@

from ansible.module_utils.network.nxos.nxos import load_config, run_commands
from ansible.module_utils.network.nxos.nxos import nxos_argument_spec, check_args
from ansible.module_utils.network.nxos.nxos import get_capabilities
from ansible.module_utils.basic import AnsibleModule


def get_platform_id(module):
info = get_capabilities(module).get('device_info', {})
return (info.get('network_os_platform', ''))


def execute_show_command(command, module):
command = {
'command': command,
Expand Down Expand Up @@ -110,6 +116,11 @@ def get_snmp_traps(group, module):
'rf', 'rmon', 'snmp', 'storm-control', 'stpx',
'switchfabric', 'syslog', 'sysmgr', 'system', 'upgrade',
'vtp']

if 'all' in group and 'N3K-C35' in get_platform_id(module):
module.warn("Platform does not support bfd traps; bfd ignored for 'group: all' request")
feature_list.remove('bfd')

for each in feature_list:
for line in body:
if each == 'ospf':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

- name: Setup - Remove snmp_traps if configured
nxos_snmp_traps: &remove
group: all
group: all
provider: "{{ connection }}"
state: disabled

- block:
- name: Configure one snmp trap group
- name: Configure one snmp trap group
nxos_snmp_traps: &config
group: bridge
group: bridge
provider: "{{ connection }}"
state: enabled
register: result
Expand Down Expand Up @@ -60,10 +60,9 @@
- name: Idempotence Check
nxos_snmp_traps: *config1
register: result
when: imagetag is not search("I2|I7|D1")

- assert: *false
when: imagetag is not search("I2|I7|D1")
when: imagetag is not search("I2|I7|D1")

- name: Cleanup
nxos_snmp_traps: *remove
Expand Down

0 comments on commit 0e0c2a7

Please sign in to comment.