mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-07-30 11:24:50 +00:00
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.
This commit is contained in:
@@ -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:
|
|||||||
"""
|
"""
|
||||||
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.
|
||||||
|
|||||||
Reference in New Issue
Block a user