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 structured output bug in nxos_user module #36193

Merged
merged 1 commit into from
Feb 16, 2018
Merged
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
5 changes: 4 additions & 1 deletion lib/ansible/modules/network/nxos/nxos_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,10 @@ def parse_password(data):


def parse_roles(data):
configured_roles = data.get('TABLE_role')['ROW_role']
configured_roles = None
if 'TABLE_role' in data:
configured_roles = data.get('TABLE_role')['ROW_role']
Copy link
Member

Choose a reason for hiding this comment

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

@mikewiebe get takes care of NoneType when the data doesn't have the key TABLE_role. It returns None. The error appears to be because the NoneType looking for the ROW_role key.
Checking for TABLE_role key when using get is not justified.
So Maybe remove get from this line? configured_roles = data['TABLE_role']['ROW_role']

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. I will remove the get.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@trishnaguha Re-thinking this change. I would prefer to leave the get as a safety measure. It's not hurting anything and will prevent the module from generating an error. I have seen cases where different Nexus versions use different key names. Risk is small but still exists.

Copy link
Member

Choose a reason for hiding this comment

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

ack. merging this in since this isn't a blocker.


roles = list()
if configured_roles:
for item in to_list(configured_roles):
Expand Down