mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-05-06 13:23:14 +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):
|
||||
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():
|
||||
return api.env.domain
|
||||
|
||||
@@ -699,6 +707,18 @@ else:
|
||||
"""
|
||||
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):
|
||||
"""
|
||||
Fail module execution if one of the invalid parameters is not None.
|
||||
|
||||
Reference in New Issue
Block a user