Skip to content
Snippets Groups Projects
Commit ca0aed54 authored by Rafael Guterres Jeffman's avatar Rafael Guterres Jeffman
Browse files

ansible_module_utils: Add method to get parameters as lowercase.

Many module member attributes must be handled in a case insensitive
manner. To ease handling these cases, a function and a method to get
the module parameters converted to lowercase is provided.
parent 48d0b2f5
No related branches found
No related tags found
No related merge requests found
...@@ -397,6 +397,14 @@ else: ...@@ -397,6 +397,14 @@ else:
def module_params_get(module, name): def module_params_get(module, name):
return _afm_convert(module.params.get(name)) return _afm_convert(module.params.get(name))
def module_params_get_lowercase(module, name):
value = _afm_convert(module.params.get(name))
if isinstance(value, list):
value = [v.lower() for v in value]
if isinstance(value, (str, unicode)):
value = value.lower()
return value
def api_get_domain(): def api_get_domain():
return api.env.domain return api.env.domain
...@@ -699,6 +707,18 @@ else: ...@@ -699,6 +707,18 @@ else:
""" """
return module_params_get(self, name) return module_params_get(self, name)
def params_get_lowercase(self, name):
"""
Retrieve value set for module parameter as lowercase, if not None.
Parameters
----------
name: string
The name of the parameter to retrieve.
"""
return module_params_get_lowercase(self, name)
def params_fail_used_invalid(self, invalid_params, state, action=None): def params_fail_used_invalid(self, invalid_params, state, action=None):
""" """
Fail module execution if one of the invalid parameters is not None. Fail module execution if one of the invalid parameters is not None.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment