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

Backport PR to fix the bug 57215 & 56300 under Nios Host_Record module #57347

Merged
merged 4 commits into from
Jun 12, 2019
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions changelogs/fragments/57221-nios-host-record-bug-fix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bugfixes:
- This PR fixes the issue raised where idempotency was failing when DNS bypassing was set to False and also exception
error faced in nios_host_reord - https://github.com/ansible/ansible/pull/57221.
Copy link
Contributor

Choose a reason for hiding this comment

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

Note, You don't need to say "This PR" in a changelog. The end user will read the changelog as a part of the entire release rather than associated with a specific PR. I believe that common style would be something like

Fix a traceback and idempotency in nios_host_record when DNS bypassing was set to False. #57221

Not a blocker for the backport

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@abadger Thanks and duly noted

23 changes: 20 additions & 3 deletions lib/ansible/module_utils/net_tools/nios/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,17 +265,34 @@ def run(self, ib_obj_type, ib_spec):
else:
proposed_object[key] = self.module.params[key]

# If configure_by_dns is set to False, then delete the default dns set in the param else throw exception
if not proposed_object.get('configure_for_dns') and proposed_object.get('view') == 'default'\
and ib_obj_type == NIOS_HOST_RECORD:
del proposed_object['view']
elif not proposed_object.get('configure_for_dns') and proposed_object.get('view') != 'default'\
and ib_obj_type == NIOS_HOST_RECORD:
self.module.fail_json(msg='DNS Bypass is not allowed if DNS view is set other than \'default\'')

if ib_obj_ref:
if len(ib_obj_ref) > 1:
for each in ib_obj_ref:
if ('ipv4addr' in each) and ('ipv4addr' in proposed_object)\
and each['ipv4addr'] == proposed_object['ipv4addr']:
# To check for existing A_record with same name with input A_record by IP
if each.get('ipv4addr') and each.get('ipv4addr') == proposed_object.get('ipv4addr'):
current_object = each
# To check for existing Host_record with same name with input Host_record by IP
elif each.get('ipv4addrs')[0].get('ipv4addr') and each.get('ipv4addrs')[0].get('ipv4addr')\
== proposed_object.get('ipv4addrs')[0].get('ipv4addr'):
current_object = each
# Else set the current_object with input value
else:
current_object = obj_filter
ref = None
else:
current_object = ib_obj_ref[0]
if 'extattrs' in current_object:
current_object['extattrs'] = flatten_extattrs(current_object['extattrs'])
ref = current_object.pop('_ref')
if current_object.get('_ref'):
ref = current_object.pop('_ref')
else:
current_object = obj_filter
ref = None
Expand Down