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 for nxos_snmp_host issues #39642

Merged
merged 4 commits into from May 3, 2018
Merged

Fix for nxos_snmp_host issues #39642

merged 4 commits into from May 3, 2018

Conversation

saichint
Copy link
Contributor

@saichint saichint commented May 2, 2018

SUMMARY

fixes #39641

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

nxos_snmp_host

ANSIBLE VERSION
ansible 2.6.0 (devel fed20b825f) last updated 2018/02/15 12:51:12 (GMT -400)
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /root/agents-ci/ansible/lib/ansible
  executable location = /root/agents-ci/ansible/bin/ansible
  python version = 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4]
ADDITIONAL INFORMATION
  • This PR fixes nxos_snmp_host issues #39641
  • Integration tests are enhanced for various platforms and version 1,2 and 3.
  • All tests pass on all platforms

@ansibot
Copy link
Contributor

ansibot commented May 2, 2018

@ansibot ansibot added bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. networking Network category nxos Cisco NXOS community support:core This issue/PR relates to code supported by the Ansible Engineering Team. support:network This issue/PR relates to code supported by the Ansible Network Team. test This PR relates to tests. labels May 2, 2018
@@ -1197,6 +1197,7 @@ lib/ansible/modules/network/nxos/nxos_pim_interface.py E326
lib/ansible/modules/network/nxos/nxos_pim_rp_address.py E326
lib/ansible/modules/network/nxos/nxos_reboot.py E325
lib/ansible/modules/network/nxos/nxos_smu.py E324
lib/ansible/modules/network/nxos/nxos_snmp_host.py E324
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New ignores should not be added. The underlying issue should be resolved. If the issue is in module_utils or docs fragments, the fix should be done in a separate PR.

Copy link
Contributor Author

@saichint saichint May 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done deliberately to maintain backward compatibility due to the previous code bugs.

Here is the long explanation:

The defaults for snmp_type and snmp_version are 'trap' and 'v1'.
There are 4 different CLIs for nxos_snmp_host.

snmp-server host 1.1.1.1 informs version 2c public udp-port 222
snmp-server host 1.1.1.1 use-vrf default udp-port 222
snmp-server host 1.1.1.1 filter-vrf management udp-port 222
snmp-server host 1.1.1.1 source-interface Ethernet1/1

So basically the user can add use-vrf, filter-vrf and source interface in different tasks without specifying the version and type if the host ip(and udp port) already exists (the first CLI). If we define the defaults in the argument_spec (which is what is needed if we have to get rid of the ignores), the defaults of v1 and trap type are used which is incorrect, as the type is 'inform' and version is '2c' for the existing configuration. So the configuration fails.

The only other way is to make the version and trap type as 'required' parameters but then older playbooks from previous versions cannot work any longer because they were not 'required' before.
Hence this ignore is added. If the code was written properly in the beginning this could have been avoided but I don't see any other way. And please remember that this PR resolves some very MAJOR issues.
We can make a decision to ignore the backward compatibility all together since this module is broken completely before. In that case, I can take make the version as type as 'required' and remove the new ignores.
Which option do you suggest?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the default from the argument spec is itself a non-backwards compatible change. Any playbook which previously relied on the default of 'trap' will now use None instead. However, if that is indeed the only way to fix the issue then that change is unavoidable.

However, in that case, the fix for the validation error is simple. Remove the default from the documentation so it matches the actual default.

The same is true for the version parameter as well. The default in the docs must match the actual default in the arg spec.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. If you look at the code, the way it works is that, if there is no existing snmp host, internally the code will make the version as 1 and type as trap (even though they are not defined in the arg spec). If there is an existing host, it will use the values from that host. So 'None' will not be an issue.
However, if we remove the defaults from documentation to match the arg spec, then the defaults are 'truly' removed and user MUST specify them always which breaks the backward compatibility. Since you are saying that the doc MUST match the arg spec no matter what, I can do by removing the defaults all together for type and version. But as I mentioned, old playbooks won't work if they have no do not specify the version and type.
Just wanted to clarify this before making changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simply remove the default: entries from the version and snmp_type docs. The logic in the code requires no additional changes.

With that change the docs will match the defaults in the arg spec. Any other default-like behavior that occurs outside of the argument spec isn't a true default and should be documented in the description instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattclay Thanks for the comments. Made the changes and removed the E324 ignore.

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label May 2, 2018
@ansibot ansibot removed the support:core This issue/PR relates to code supported by the Ansible Engineering Team. label May 2, 2018
@trishnaguha trishnaguha self-assigned this May 3, 2018
@trishnaguha trishnaguha merged commit f99bae1 into ansible:devel May 3, 2018
@saichint saichint deleted the snmp_host branch May 3, 2018 16:09
@trishnaguha trishnaguha moved this from In Review to Need CP into 2.5.3 in zzz NOT USED: Networking Bugs May 4, 2018
@trishnaguha trishnaguha moved this from Need CP into 2.5.3 to Done in zzz NOT USED: Networking Bugs May 4, 2018
@trishnaguha
Copy link
Member

cherry-picked to 2.5

trishnaguha pushed a commit to trishnaguha/ansible that referenced this pull request May 4, 2018
* fix snmp_host issues

* source files

* fix shippable

* remove defaults to match arg spec

(cherry picked from commit f99bae1)
trishnaguha added a commit that referenced this pull request May 4, 2018
* Handle nxos_feature issue where json isn't supported (#39150)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
(cherry picked from commit 9eff1f1)

* Integration Tests only: nxos_snmp_contact (#39318)

* add integration test cases for snmp_contact

* removing unnecessary files

(cherry picked from commit bdb75cd)

* fix nxos_ntp issues (#39178)

* fix nxos_ntp issues

* review comments

* fix idempotent fail case

(cherry picked from commit 2f99a17)

* nxos_interface: AttributeError: 'NoneType' object has no attribute 'group' (#38544)

This fixes an issue we recently encounteredi with nxos_interface:

```
Traceback (most recent call last):
  File "/tmp/ansible_JmLoba/ansible_module_nxos_interface.py", line 777, in main
    have = map_config_to_obj(want, module)
  File "/tmp/ansible_JmLoba/ansible_module_nxos_interface.py", line 606, in map_config_to_obj
    obj['speed'] = re.search(r'speed (\d+)', body).group(1)
AttributeError: 'NoneType' object has no attribute 'group'
```

(cherry picked from commit dca6e2d)

* fix nxos_snmp_community issues (#39258)

(cherry picked from commit 1afec5a)

* Add aggregate example in nxos_l2_interface module doc (#39275)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
(cherry picked from commit 86817cd)

* Fix misuse of 'self' in lib/ansible/module_utils/network/eos/eos.py. … (#39074)

* Fix misuse of 'self' in lib/ansible/module_utils/network/eos/eos.py. Method load_config

* Fix all instances of self.config(self,...

(cherry picked from commit 80d7e22)

* Fix for nxos_snmp_host issues (#39642)

* fix snmp_host issues

* source files

* fix shippable

* remove defaults to match arg spec

(cherry picked from commit f99bae1)

* fix nxos_snmp_traps issues (#39444)

* fix snmp_traps code

* add IT cases

* fix shippable

* fix shippable without ignore

(cherry picked from commit 99748cb)

* changelog

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
oolongbrothers pushed a commit to oolongbrothers/ansible that referenced this pull request May 12, 2018
* fix snmp_host issues

* source files

* fix shippable

* remove defaults to match arg spec
oolongbrothers pushed a commit to oolongbrothers/ansible that referenced this pull request May 14, 2018
* fix snmp_host issues

* source files

* fix shippable

* remove defaults to match arg spec
oolongbrothers pushed a commit to oolongbrothers/ansible that referenced this pull request May 14, 2018
* fix snmp_host issues

* source files

* fix shippable

* remove defaults to match arg spec
tonal pushed a commit to tonal/ansible that referenced this pull request May 15, 2018
* fix snmp_host issues

* source files

* fix shippable

* remove defaults to match arg spec
oolongbrothers pushed a commit to oolongbrothers/ansible that referenced this pull request May 15, 2018
* fix snmp_host issues

* source files

* fix shippable

* remove defaults to match arg spec
oolongbrothers pushed a commit to oolongbrothers/ansible that referenced this pull request May 15, 2018
* fix snmp_host issues

* source files

* fix shippable

* remove defaults to match arg spec
ilicmilan pushed a commit to ilicmilan/ansible that referenced this pull request Nov 7, 2018
* fix snmp_host issues

* source files

* fix shippable

* remove defaults to match arg spec
@dagwieers dagwieers added the cisco Cisco technologies label Feb 23, 2019
@ansible ansible locked and limited conversation to collaborators May 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug. cisco Cisco technologies core_review In order to be merged, this PR must follow the core review workflow. module This issue/PR relates to a module. networking Network category nxos Cisco NXOS community support:network This issue/PR relates to code supported by the Ansible Network Team. test This PR relates to tests.
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

nxos_snmp_host issues
5 participants