mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-08-01 04:14:42 +00:00
ansible_freeipa_module: New functions module_params_get and _afm_convert
The module_params_get function can and should be used as a replacement of ansible_module.params.get. For Python2 it is needed to convert parameters to unicode. Otherwise there will be an error in the FreeIPA API command. The private function _afm_convert has been added to do the conversion recursively.
This commit is contained in:
@@ -190,3 +190,21 @@ def compare_args_ipa(module, args, ipa):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def _afm_convert(value):
|
||||||
|
if value is not None:
|
||||||
|
if isinstance(value, list):
|
||||||
|
return [_afm_convert(x) for x in value]
|
||||||
|
elif isinstance(value, dict):
|
||||||
|
return {_afm_convert(k): _afm_convert(v) for k, v in value.items()}
|
||||||
|
elif isinstance(value, str):
|
||||||
|
return to_text(value)
|
||||||
|
else:
|
||||||
|
return value
|
||||||
|
else:
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
def module_params_get(module, name):
|
||||||
|
return _afm_convert(module.params.get(name))
|
||||||
|
|||||||
Reference in New Issue
Block a user