Skip to content

Commit

Permalink
[FIX] fixed use_for_ea_inheritance update operation on host record
Browse files Browse the repository at this point in the history
  • Loading branch information
JkhatriInfobox committed Sep 26, 2024
1 parent 06227fe commit f851f32
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions plugins/module_utils/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ def run(self, ib_obj_type, ib_spec):
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']

if ib_obj_ref:
if len(ib_obj_ref) > 1:
for each in ib_obj_ref:
Expand Down Expand Up @@ -511,22 +510,21 @@ def run(self, ib_obj_type, ib_spec):
result['changed'] = True
if not self.module.check_mode and res is None:
proposed_object = self.on_update(proposed_object, ib_spec)
self.update_object(ref, proposed_object)
res = self.update_object(ref, proposed_object)
result['changed'] = True

if ib_obj_type == NIOS_HOST_RECORD and res:
# WAPI always reset the use_for_ea_inheritance for each update operation
# Handle use_for_ea_inheritance flag changes for IPv4addr in a host record
# Fetch the updated reference of host to avoid drift.
host_ref = self.connector.get_object(res)

# Create a dictionary for quick lookups
ref_dict = {obj['ipv4addr']: obj['_ref'] for obj in host_ref['ipv4addrs']}
for proposed in proposed_object['ipv4addrs']:
ipv4addr = proposed['ipv4addr']
if ipv4addr in ref_dict and 'use_for_ea_inheritance' in proposed:
self.update_object(ref_dict[ipv4addr], {'use_for_ea_inheritance': proposed['use_for_ea_inheritance']})

host_ref = self.connector.get_object(obj_type=str(res), return_fields=['ipv4addrs'])
if host_ref:
# Create a dictionary for quick lookups
ref_dict = {obj['ipv4addr']: obj['_ref'] for obj in host_ref['ipv4addrs']}
for proposed in proposed_object['ipv4addrs']:
ipv4addr = proposed['ipv4addr']
if ipv4addr in ref_dict and 'use_for_ea_inheritance' in proposed:
self.update_object(ref_dict[ipv4addr], {'use_for_ea_inheritance': proposed['use_for_ea_inheritance']})
elif state == 'absent':
if ref is not None:
if 'ipv4addrs' in proposed_object:
Expand Down Expand Up @@ -858,7 +856,6 @@ def get_object_ref(self, module, ib_obj_type, obj_filter, ib_spec):
]
return_fields.extend(ipv4addrs_return)
return_fields.extend(ipv6addrs_return)

ib_obj = self.get_object(ib_obj_type, test_obj_filter.copy(), return_fields=return_fields)

# prevents creation of a new A record with 'new_ipv4addr' when A record with a particular 'old_ipv4addr' is not found
Expand Down

0 comments on commit f851f32

Please sign in to comment.