mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-05-08 06:13:21 +00:00
Merge pull request #652 from rjeffman/ipaansiblemodule_fail_if_invalid
Standardize algorithm to verify if invalid argument was used.
This commit is contained in:
@@ -699,6 +699,30 @@ else:
|
||||
"""
|
||||
return module_params_get(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.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
invalid_params:
|
||||
List of parameters that must value 'None'.
|
||||
state:
|
||||
State being tested.
|
||||
action:
|
||||
Action being tested (optional).
|
||||
|
||||
"""
|
||||
if action is None:
|
||||
msg = "Argument '{0}' can not be used with state '{1}'"
|
||||
else:
|
||||
msg = "Argument '{0}' can not be used with action "\
|
||||
"'{2}' and state '{1}'"
|
||||
|
||||
for param in invalid_params:
|
||||
if self.params.get(param) is not None:
|
||||
self.fail_json(msg=msg.format(param, state, action))
|
||||
|
||||
def ipa_command(self, command, name, args):
|
||||
"""
|
||||
Execute an IPA API command with a required `name` argument.
|
||||
|
||||
Reference in New Issue
Block a user