Skip to content

Commit e2ea26a

Browse files
committed
ansible_freeipa_module.py: New PARAM_MAPPING and query support
New functions and methods have been added to reduce code complexity and duplication in several modules, as well as to enable query mode in the modules. New functions: gen_member_add_del_lists Compute member add/del lists for all member params marked with "member": True in PARAM_MAPPING. Handles sync, add-only and remove-only modes based on action and state. gen_member_args_from_mapping Build a member args dict for compare_args_ipa() from PARAM_MAPPING. Replaces per-module gen_member_args() functions. New static methods: gen_args_from_mapping Generate IPA command args dict from PARAM_MAPPING. Replaces per-module gen_args() functions. extract_params Extract parameter values from module params using PARAM_MAPPING. extract_params_from_entry Extract parameter values from a users/hosts dict entry using PARAM_MAPPING. build_query_param_settings Build query parameter settings from PARAM_MAPPING and QUERY_FIELDS for use with execute_query. New methods: execute_query Execute query state for modules supporting state: query. _extract_query_fields Extract requested fields from a query result using the mapping. The params_fail_used_invalid method has been extended to accept optional params and param_mapping arguments for use with extracted params dicts. PARAM_MAPPING is an ordered dict that maps Ansible parameter names to their metadata. Each entry is a dict with optional keys: "api_name" IPA attribute name if different from the Ansible parameter name. "gen_args" Set to False to exclude the parameter from gen_args_from_mapping (used for members and parameters handled separately). "member" Set to True to include the parameter in gen_member_add_del_lists and gen_member_args_from_mapping. "module_param" Set to True for top-level module parameters that are not part of the entity (e.g. action, state, query_param, users). "return_only" Set to True for parameters that are only returned by IPA and never sent (excluded from gen_args_from_mapping). "nonempty_list" Set to True if an empty list value should not be sent to IPA. "lowercase" Set to True to lowercase values before comparison. "convert_to" Conversion type for the parameter value (e.g. "str", "int", "bool"). An empty dict {} means the Ansible name equals the IPA attribute name and the parameter is included in gen_args_from_mapping with no special handling. For query support a QUERY_FIELDS dict is needed with "prefix" for the grouping key in PKEY_ONLY results, "primary_key" for the IPA name attribute and "base" for the list of essential field names returned by default.
1 parent 4f6575b commit e2ea26a

1 file changed

Lines changed: 405 additions & 2 deletions

File tree

0 commit comments

Comments
 (0)