Skip to content

Commit

Permalink
Fixed BUGS for ENV Variables wapi_version and max_results
Browse files Browse the repository at this point in the history
  • Loading branch information
JkhatriInfobox committed Dec 7, 2023
1 parent 5dcb52e commit f4a1c8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion plugins/doc_fragments/nios.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ModuleDocFragment(object):
wapi_version:
description:
- Specifies the version of WAPI to use
- Value can also be specified using C(INFOBLOX_WAP_VERSION) environment
- Value can also be specified using C(INFOBLOX_WAPI_VERSION) environment
variable.
- Until ansible 2.8 the default WAPI was 1.4
type: str
Expand Down
16 changes: 9 additions & 7 deletions plugins/module_utils/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@
'http_pool_connections': dict(type='int', default=10),
'http_pool_maxsize': dict(type='int', default=10),
'max_retries': dict(type='int', default=3, fallback=(env_fallback, ['INFOBLOX_MAX_RETRIES'])),
'wapi_version': dict(default='2.9', fallback=(env_fallback, ['INFOBLOX_WAP_VERSION'])),
'max_results': dict(type='int', default=1000, fallback=(env_fallback, ['INFOBLOX_MAX_RETRIES']))
'wapi_version': dict(default='2.9', fallback=(env_fallback, ['INFOBLOX_WAPI_VERSION'])),
'max_results': dict(type='int', default=1000, fallback=(env_fallback, ['INFOBLOX_MAX_RESULTS']))
}


Expand Down Expand Up @@ -120,7 +120,12 @@ def get_connector(*args, **kwargs):
# explicitly set
env = ('INFOBLOX_%s' % key).upper()
if env in os.environ:
kwargs[key] = os.environ.get(env)
if NIOS_PROVIDER_SPEC[key].get('type') == 'bool':
kwargs[key] = eval(os.environ.get(env).title())
elif NIOS_PROVIDER_SPEC[key].get('type') == 'int':
kwargs[key] = eval(os.environ.get(env))
else:
kwargs[key] = os.environ.get(env)

if 'validate_certs' in kwargs.keys():
kwargs['ssl_verify'] = kwargs['validate_certs']
Expand Down Expand Up @@ -755,7 +760,7 @@ def get_object_ref(self, module, ib_obj_type, obj_filter, ib_spec):
test_obj_filter['text'] = txt

# removing Port param from get params for NIOS_DTC_MONITOR_TCP
if (ib_obj_type == NIOS_DTC_MONITOR_TCP):
elif (ib_obj_type == NIOS_DTC_MONITOR_TCP):
test_obj_filter = dict([('name', obj_filter['name'])])

# check if test_obj_filter is empty copy passed obj_filter
Expand All @@ -779,9 +784,6 @@ def get_object_ref(self, module, ib_obj_type, obj_filter, ib_spec):
except TypeError:
ipaddr = obj_filter['ipv4addr']
test_obj_filter['ipv4addr'] = ipaddr
# prevents creation of a new A record with 'new_ipv4addr' when A record with a particular 'old_ipv4addr' is not found
if old_ipv4addr_exists and ib_obj is None:
raise Exception("A Record with ipv4addr: '%s' is not found" % (ipaddr))
ib_obj = self.get_object(ib_obj_type, test_obj_filter.copy(), return_fields=list(ib_spec.keys()))
# prevents creation of a new A record with 'new_ipv4addr' when A record with a particular 'old_ipv4addr' is not found
if old_ipv4addr_exists and ib_obj is None:
Expand Down

0 comments on commit f4a1c8a

Please sign in to comment.