Skip to content

Commit

Permalink
Fixes Unable update/delete EA's and sanity fix (#180)
Browse files Browse the repository at this point in the history
* Fixes Unable update/delete EA's and sanity fix

* Fixes sanity pep8 issue
  • Loading branch information
hemanthKa677 authored Apr 24, 2023
1 parent ea7ad87 commit 92d6510
Show file tree
Hide file tree
Showing 24 changed files with 22 additions and 25 deletions.
24 changes: 22 additions & 2 deletions plugins/module_utils/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
from ansible.module_utils._text import to_text
from ansible.module_utils.basic import env_fallback
from ansible.module_utils.common.validation import check_type_dict, safe_eval
from ansible.module_utils.six import string_types

try:
from infoblox_client.connector import Connector
Expand Down Expand Up @@ -350,7 +349,7 @@ def run(self, ib_obj_type, ib_spec):
# The WAPI API will never return the "create_token" field that causes a difference
# with the defaults of the module. To prevent this we remove the "create_token" option
# if it has not been set to true.
if(proposed_object.get("create_token") is not True):
if (proposed_object.get("create_token") is not True):
proposed_object.pop("create_token")

if (ib_obj_type == NIOS_IPV4_NETWORK or ib_obj_type == NIOS_IPV6_NETWORK):
Expand Down Expand Up @@ -544,6 +543,19 @@ def issubset(self, item, objects):
if item in obj:
return True

def compare_extattrs(self, current_extattrs, proposed_extattrs):
'''Compare current extensible attributes to given extensible
attribute, if length is not equal returns false , else
checks the value of keys in proposed extattrs'''
if len(current_extattrs) != len(proposed_extattrs):
return False
else:
for key, proposed_item in iteritems(proposed_extattrs):
current_item = current_extattrs.get(key)
if current_item != proposed_item:
return False
return True

def compare_objects(self, current_object, proposed_object):
for key, proposed_item in iteritems(proposed_object):
current_item = current_object.get(key)
Expand Down Expand Up @@ -571,6 +583,14 @@ def compare_objects(self, current_object, proposed_object):
# Compare the items of the dict to see if they are equal. A
# difference stops the comparison and returns false. If they
# are equal move on to the next item

# Checks if extattrs existing in proposed object
if key == 'extattrs':
current_extattrs = current_object.get(key)
proposed_extattrs = proposed_object.get(key)
if not self.compare_extattrs(current_extattrs, proposed_extattrs):
return False

if self.compare_objects(current_item, proposed_item) is False:
return False
else:
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/nios_a_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@
RETURN = ''' # '''

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import iteritems
from ..module_utils.api import WapiModule
from ..module_utils.api import NIOS_A_RECORD
from ..module_utils.api import normalize_ib_spec
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/nios_aaaa_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
RETURN = ''' # '''

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import iteritems
from ..module_utils.api import WapiModule
from ..module_utils.api import NIOS_AAAA_RECORD
from ..module_utils.api import normalize_ib_spec
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/nios_cname_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
RETURN = ''' # '''

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import iteritems
from ..module_utils.api import WapiModule
from ..module_utils.api import NIOS_CNAME_RECORD
from ..module_utils.api import normalize_ib_spec
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/nios_dtc_lbdn.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@
from ..module_utils.api import NIOS_DTC_LBDN
from ..module_utils.api import WapiModule
from ..module_utils.api import normalize_ib_spec
from ansible.module_utils.six import iteritems
from ansible.module_utils.basic import AnsibleModule


Expand Down
1 change: 0 additions & 1 deletion plugins/modules/nios_dtc_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@
from ..module_utils.api import NIOS_DTC_POOL
from ..module_utils.api import WapiModule
from ..module_utils.api import normalize_ib_spec
from ansible.module_utils.six import iteritems
from ansible.module_utils.basic import AnsibleModule


Expand Down
1 change: 0 additions & 1 deletion plugins/modules/nios_dtc_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
RETURN = ''' # '''

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import iteritems
from ..module_utils.api import WapiModule
from ..module_utils.api import NIOS_DTC_SERVER
from ..module_utils.api import normalize_ib_spec
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/nios_member.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,6 @@
RETURN = ''' # '''

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import iteritems
from ..module_utils.api import WapiModule
from ..module_utils.api import NIOS_MEMBER
from ..module_utils.api import normalize_ib_spec
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/nios_mx_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@
RETURN = ''' # '''

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import iteritems
from ..module_utils.api import WapiModule
from ..module_utils.api import NIOS_MX_RECORD
from ..module_utils.api import normalize_ib_spec
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/nios_naptr_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@
RETURN = ''' # '''

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import iteritems
from ..module_utils.api import WapiModule
from ..module_utils.api import normalize_ib_spec

Expand Down
1 change: 0 additions & 1 deletion plugins/modules/nios_restartservices.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
RETURN = ''' # '''

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import iteritems
from ..module_utils.api import WapiModule
from ..module_utils.api import normalize_ib_spec

Expand Down
1 change: 0 additions & 1 deletion plugins/modules/nios_srv_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@
RETURN = ''' # '''

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import iteritems
from ..module_utils.api import WapiModule
from ..module_utils.api import NIOS_SRV_RECORD
from ..module_utils.api import normalize_ib_spec
Expand Down
1 change: 0 additions & 1 deletion plugins/modules/nios_txt_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
RETURN = ''' # '''

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import iteritems
from ..module_utils.api import WapiModule
from ..module_utils.api import normalize_ib_spec

Expand Down
1 change: 0 additions & 1 deletion tests/unit/plugins/module_utils/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from ansible_collections.infoblox.nios_modules.tests.unit.compat import unittest
from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock
from ansible.module_utils.common.validation import check_type_dict
from ansible_collections.infoblox.nios_modules.plugins.module_utils import api


Expand Down
1 change: 0 additions & 1 deletion tests/unit/plugins/modules/test_nios_a_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from ansible_collections.infoblox.nios_modules.plugins.modules import nios_a_record
from ansible_collections.infoblox.nios_modules.plugins.module_utils import api
from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock
from ansible.module_utils.common.validation import check_type_dict
from .test_nios_module import TestNiosModule, load_fixture


Expand Down
1 change: 0 additions & 1 deletion tests/unit/plugins/modules/test_nios_aaaa_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from ansible_collections.infoblox.nios_modules.plugins.modules import nios_aaaa_record
from ansible_collections.infoblox.nios_modules.plugins.module_utils import api
from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock
from ansible.module_utils.common.validation import check_type_dict
from .test_nios_module import TestNiosModule, load_fixture


Expand Down
1 change: 0 additions & 1 deletion tests/unit/plugins/modules/test_nios_cname_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from ansible_collections.infoblox.nios_modules.plugins.modules import nios_cname_record
from ansible_collections.infoblox.nios_modules.plugins.module_utils import api
from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock
from ansible.module_utils.common.validation import check_type_dict
from .test_nios_module import TestNiosModule, load_fixture


Expand Down
1 change: 0 additions & 1 deletion tests/unit/plugins/modules/test_nios_dns_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from ansible_collections.infoblox.nios_modules.plugins.modules import nios_dns_view
from ansible_collections.infoblox.nios_modules.plugins.module_utils import api
from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock
from ansible.module_utils.common.validation import check_type_dict
from .test_nios_module import TestNiosModule, load_fixture


Expand Down
1 change: 0 additions & 1 deletion tests/unit/plugins/modules/test_nios_host_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from ansible_collections.infoblox.nios_modules.plugins.modules import nios_host_record
from ansible_collections.infoblox.nios_modules.plugins.module_utils import api
from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock
from ansible.module_utils.common.validation import check_type_dict
from .test_nios_module import TestNiosModule, load_fixture


Expand Down
1 change: 0 additions & 1 deletion tests/unit/plugins/modules/test_nios_mx_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from ansible_collections.infoblox.nios_modules.plugins.modules import nios_mx_record
from ansible_collections.infoblox.nios_modules.plugins.module_utils import api
from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock
from ansible.module_utils.common.validation import check_type_dict
from .test_nios_module import TestNiosModule, load_fixture


Expand Down
1 change: 0 additions & 1 deletion tests/unit/plugins/modules/test_nios_naptr_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from ansible_collections.infoblox.nios_modules.plugins.modules import nios_naptr_record
from ansible_collections.infoblox.nios_modules.plugins.module_utils import api
from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock
from ansible.module_utils.common.validation import check_type_dict
from .test_nios_module import TestNiosModule, load_fixture


Expand Down
1 change: 0 additions & 1 deletion tests/unit/plugins/modules/test_nios_network_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from ansible_collections.infoblox.nios_modules.plugins.modules import nios_network_view
from ansible_collections.infoblox.nios_modules.plugins.module_utils import api
from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock
from ansible.module_utils.common.validation import check_type_dict
from .test_nios_module import TestNiosModule, load_fixture


Expand Down
1 change: 0 additions & 1 deletion tests/unit/plugins/modules/test_nios_nsgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from ansible_collections.infoblox.nios_modules.plugins.modules import nios_nsgroup
from ansible_collections.infoblox.nios_modules.plugins.module_utils import api
from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock
from ansible.module_utils.common.validation import check_type_dict
from .test_nios_module import TestNiosModule, load_fixture


Expand Down
1 change: 0 additions & 1 deletion tests/unit/plugins/modules/test_nios_srv_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from ansible_collections.infoblox.nios_modules.plugins.modules import nios_srv_record
from ansible_collections.infoblox.nios_modules.plugins.module_utils import api
from ansible_collections.infoblox.nios_modules.tests.unit.compat.mock import patch, MagicMock, Mock
from ansible.module_utils.common.validation import check_type_dict
from .test_nios_module import TestNiosModule, load_fixture


Expand Down

0 comments on commit 92d6510

Please sign in to comment.