Skip to content

Commit

Permalink
fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
nitish-ks committed Jan 7, 2025
2 parents 05d48db + 6cbd30d commit c8a7034
Show file tree
Hide file tree
Showing 15 changed files with 844 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ansible-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ jobs:
echo $ANSIBLE_NIOSSIM_CONTAINER
ansible-test integration -v --color --retry-on-error --continue-on-error --diff --python ${{ matrix.python-version }} --docker --coverage
env:
ANSIBLE_NIOSSIM_CONTAINER: quay.io/ansible/nios-test-container:6.0.0
ANSIBLE_NIOSSIM_CONTAINER: quay.io/ansible/nios-test-container:7.0.0
working-directory: /home/runner/.ansible/collections/ansible_collections/infoblox/nios_modules/

# ansible-test support producing code coverage date
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The `infoblox.nios_modules` collection has the following content:

- `nios_a_record` – Configure Infoblox NIOS A records
- `nios_aaaa_record` – Configure Infoblox NIOS AAAA records
- `nios_adminuser` – Configure Infoblox NIOS Adminuser
- `nios_cname_record` – Configure Infoblox NIOS CNAME records
- `nios_dns_view` – Configure Infoblox NIOS DNS views
- `nios_dtc_lbdn` – Configure Infoblox NIOS DTC LBDN records
Expand Down
41 changes: 25 additions & 16 deletions plugins/module_utils/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
NIOS_DTC_TOPOLOGY = 'dtc:topology'
NIOS_EXTENSIBLE_ATTRIBUTE = 'extensibleattributedef'
NIOS_VLAN = 'vlan'
NIOS_ADMINUSER = 'adminuser'

NIOS_PROVIDER_SPEC = {
'host': dict(fallback=(env_fallback, ['INFOBLOX_HOST'])),
Expand Down Expand Up @@ -700,27 +701,28 @@ def compare_objects(self, current_object, proposed_object):
# If the lists are of a different length, the objects cannot be
# equal, and False will be returned before comparing the list items
# this code part will work for members' assignment
if (key in ('members', 'options', 'delegate_to', 'forwarding_servers', 'stub_members', 'vlans')
if (key in ('members', 'options', 'delegate_to', 'forwarding_servers', 'stub_members', 'vlans', 'ssh_keys')
and (len(proposed_item) != len(current_item))):
return False

# Validate the Sequence of the List data
if key in ('external_servers', 'list_values') and not self.verify_list_order(proposed_item, current_item):
return False

for subitem in proposed_item:
if current_item:
# Host IPv4addrs wont contain use_nextserver and nextserver
# If DHCP is false.
dhcp_flag = current_item[0].get('configure_for_dhcp', False)
use_nextserver = subitem.get('use_nextserver', False)
if key == 'ipv4addrs' and not dhcp_flag:
subitem.pop('use_nextserver', None)
subitem.pop('nextserver', None)
elif key == 'ipv4addrs' and dhcp_flag and not use_nextserver:
subitem.pop('nextserver', None)
if not self.issubset(subitem, current_item):
return False
if key == 'ipv4addrs':
for subitem in proposed_item:
if current_item:
# Host IPv4addrs wont contain use_nextserver and nextserver
# If DHCP is false.
dhcp_flag = current_item[0].get('configure_for_dhcp', False)
use_nextserver = subitem.get('use_nextserver', False)
if key == 'ipv4addrs' and not dhcp_flag:
subitem.pop('use_nextserver', None)
subitem.pop('nextserver', None)
elif key == 'ipv4addrs' and dhcp_flag and not use_nextserver:
subitem.pop('nextserver', None)
if not self.issubset(subitem, current_item):
return False

# If the lists are of a different length, the objects and order of element mismatch
# Ignore DHCP options while comparing due to extra num param is get response
Expand Down Expand Up @@ -770,6 +772,12 @@ def get_object_ref(self, module, ib_obj_type, obj_filter, ib_spec):
except TypeError:
name = obj_filter['name']

return_fields = list(ib_spec.keys())

if (ib_obj_type == NIOS_ADMINUSER):
if 'password' in return_fields:
return_fields.remove('password')

if old_name and new_name:
if (ib_obj_type == NIOS_HOST_RECORD):
# to check only by old_name if dns bypassing is set
Expand All @@ -793,7 +801,7 @@ def get_object_ref(self, module, ib_obj_type, obj_filter, ib_spec):
else:
test_obj_filter = dict([('name', old_name)])
# get the object reference
ib_obj = self.get_object(ib_obj_type, test_obj_filter, return_fields=list(ib_spec.keys()))
ib_obj = self.get_object(ib_obj_type, test_obj_filter, return_fields=return_fields)
if ib_obj:
obj_filter['name'] = new_name
elif old_ipv4addr_exists and (len(ib_obj) == 0):
Expand Down Expand Up @@ -864,7 +872,7 @@ def get_object_ref(self, module, ib_obj_type, obj_filter, ib_spec):
# check if test_obj_filter is empty copy passed obj_filter
else:
test_obj_filter = obj_filter
return_fields = list(ib_spec.keys())

if ib_obj_type == NIOS_HOST_RECORD:
ipv4addrs_return = [
'ipv4addrs.ipv4addr', 'ipv4addrs.mac', 'ipv4addrs.configure_for_dhcp', 'ipv4addrs.host',
Expand All @@ -875,6 +883,7 @@ 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
Loading

0 comments on commit c8a7034

Please sign in to comment.