mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-07-31 11:54:47 +00:00
Merge pull request #558 from t-woerner/compare_args_ipa_ignore_arg
ansible_freeipa_module.py: Add ignore argument to compare_args_ipa
This commit is contained in:
@@ -276,14 +276,14 @@ else:
|
|||||||
pass
|
pass
|
||||||
raise ValueError("Invalid date '%s'" % value)
|
raise ValueError("Invalid date '%s'" % value)
|
||||||
|
|
||||||
def compare_args_ipa(module, args, ipa): # noqa
|
def compare_args_ipa(module, args, ipa, ignore=None): # noqa
|
||||||
"""Compare IPA obj attrs with the command args.
|
"""Compare IPA obj attrs with the command args.
|
||||||
|
|
||||||
This function compares IPA objects attributes with the args the
|
This function compares IPA objects attributes with the args the
|
||||||
module is intending to use to call a command. This is useful to know
|
module is intending to use to call a command. ignore can be a list
|
||||||
if call to IPA server will be needed or not.
|
of attributes, that should be ignored in the comparison.
|
||||||
In other to compare we have to prepare the perform slight changes in
|
This is useful to know if a call to IPA server will be needed or not.
|
||||||
data formats.
|
In order to compare we have to perform slight changes in data formats.
|
||||||
|
|
||||||
Returns True if they are the same and False otherwise.
|
Returns True if they are the same and False otherwise.
|
||||||
"""
|
"""
|
||||||
@@ -307,7 +307,12 @@ else:
|
|||||||
if not (isinstance(args, dict) and isinstance(ipa, dict)):
|
if not (isinstance(args, dict) and isinstance(ipa, dict)):
|
||||||
raise TypeError("Expected 'dicts' to compare.")
|
raise TypeError("Expected 'dicts' to compare.")
|
||||||
|
|
||||||
for key in args.keys():
|
# Create filtered_args using ignore
|
||||||
|
if ignore is None:
|
||||||
|
ignore = []
|
||||||
|
filtered_args = [key for key in args if key not in ignore]
|
||||||
|
|
||||||
|
for key in filtered_args:
|
||||||
if key not in ipa:
|
if key not in ipa:
|
||||||
module.debug(
|
module.debug(
|
||||||
base_debug_msg + "Command key not present in IPA: %s" % key
|
base_debug_msg + "Command key not present in IPA: %s" % key
|
||||||
|
|||||||
Reference in New Issue
Block a user