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_hsrp: fix 'sh_preempt': <unknown enum:> #52858

Merged
merged 2 commits into from
Feb 27, 2019

Conversation

chrisvanheuveln
Copy link
Contributor

SUMMARY

Some older nxos images fail to set this attr value. This fix checks for unknown enum and issues a second (unstructured) call to the device to get the data.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

network/nxos/nxos_hsrp

ADDITIONAL INFORMATION

Issue seen with N9000 NXOS version 7.0(3)I7(4).

The nxos_hsrp/tests/common/sanity.yaml test will fail with idempotency issues.
The output from the defective image will display show hsrp group 100 all | json as shown:

n9k(config-if-hsrp)# show hsrp group 100 all | json
{"TABLE_grp_detail": {"ROW_grp_detail": {"sh_if_index": "Ethernet1/1",
...
, "sh_preempt": "unknown enum:<1919252225>", 
...

sh_preempt is the only affected attr but I've written the fix to allow for additional attrs as needed.

nxos_hsrp tests are now 100% pass rate with this fix.

Some older nxos images fail to set this attr value. This fix checks for
unknown enum and issues a second (unstructured) call to the device to get
the data.
@ansibot
Copy link
Contributor

ansibot commented Feb 22, 2019

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 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 new_contributor This PR is the first contribution by a new community member. nxos Cisco NXOS community support:network This issue/PR relates to code supported by the Ansible Network Team. test This PR relates to tests. labels Feb 22, 2019
@ansibot
Copy link
Contributor

ansibot commented Feb 22, 2019

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

lib/ansible/modules/network/nxos/nxos_hsrp.py:251:24: E231 missing whitespace after ':'

click here for bot help

@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Feb 22, 2019
@dagwieers dagwieers added the cisco Cisco technologies label Feb 23, 2019
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. needs_triage Needs a first human triage before being processed. labels Feb 23, 2019
@trishnaguha trishnaguha self-assigned this Feb 25, 2019
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. new_contributor This PR is the first contribution by a new community member. labels Feb 26, 2019
@trishnaguha trishnaguha dismissed a stale review February 26, 2019 07:15

Comment instead

'sh_preempt' is currently the only attr affected. Add checks for other attrs as needed.
'''
if 'unknown enum:' in hsrp_table['sh_preempt']:
cmd = {'output': 'text', 'command': command.split('|')[0]}
Copy link
Member

Choose a reason for hiding this comment

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

Does nxapi fail as well?
Does the command error out with structured json output? Or is it just for a specific key?

If the command fails for json request:
We actually have the logic already implemented in module_utils https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/network/nxos/nxos.py#L164.
When check_rc is set to retry_json, run_commands will send the command the request with non structured format if json fails.
You will just need to append the error string to if it is any different than Invalid Command or Ambiguous Command https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/network/nxos/nxos.py#L170

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this fails for nxapi as well.
The show command is successful with structured, it is only the sh_preempt key that is faulty.

[{u'TABLE_grp_detail': {u'ROW_grp_detail': {u'sh_active_router_addr': u'0.0.0.0',
 u'sh_group_num': u'100', u'sh_authentication_data': u'1234', u'sh_cur_hold_attr': u'sec',
 u'sh_ip_redund_name_attr': u'Default', u'sh_prio': u'25', u'sh_standby_router_addr': u'0.0.0.0',
 u'sh_vmac_attr': u'Default MAC', u'sh_cur_hello_attr': u'sec', u'sh_vip': u'192.0.2.2',
 u'sh_cur_hello': u'3', u'sh_vip_attr': u'config', u'sh_keystring_attr': u'unencrypted',
 u'sh_num_track_obj': u'0', u'sh_active_router_prio': u'0', u'sh_num_of_total_state_changes': u'0',
 u'sh_cfg_prio': u'25', u'sh_if_index': u'Ethernet1/1', u'sh_can_forward': u'unknown enum:<411125249>',
 u'sh_group_type': u'v4', u'sh_fwd_upper_threshold': u'25', u'sh_group_state': u'Initial',
 u'sh_cur_hold': u'10', u'sh_standby_router_prio': u'0', u'sh_fwd_lower_threshold': u'0', u'sh_group_version': u'v2',
 u'sh_preempt': u'unknown enum:<808728065>',   <-------------<< *****
 u'sh_vmac': u'0000.0c9f.f064', u'sh_ip_redund_name': u'hsrp-Eth1/1-100', 'sh_num_of_state_changes':
 u'0', u'sh_authentication_type': u'md5', u'sh_state_reason': u'(Interface Down)'}}}]

@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Feb 26, 2019
@trishnaguha trishnaguha merged commit 5dc65d0 into ansible:devel Feb 27, 2019
@chrisvanheuveln chrisvanheuveln deleted the devel-nxos_hsrp branch March 8, 2019 16:28
trishnaguha pushed a commit to trishnaguha/ansible that referenced this pull request Apr 1, 2019
* nxos_hsrp: fix 'sh_preempt': <unknown enum:>

Some older nxos images fail to set this attr value. This fix checks for
unknown enum and issues a second (unstructured) call to the device to get
the data.

* add whitespace for pep8

(cherry picked from commit 5dc65d0)
abadger pushed a commit that referenced this pull request Apr 4, 2019
* nxos_hsrp: fix 'sh_preempt': <unknown enum:>

Some older nxos images fail to set this attr value. This fix checks for
unknown enum and issues a second (unstructured) call to the device to get
the data.

* add whitespace for pep8

(cherry picked from commit 5dc65d0)
@ansible ansible locked and limited conversation to collaborators Jul 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 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
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants