Skip to content
Snippets Groups Projects
Commit b1628045 authored by Thomas Woerner's avatar Thomas Woerner
Browse files

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.
parent 3390d674
No related branches found
No related tags found
No related merge requests found
......@@ -190,3 +190,21 @@ def compare_args_ipa(module, args, ipa):
return False
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))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment