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

ansible_freeipa_module: New ipa_command_invalid_param_choices method

New IPAAnsibleModule.ipa_command_invalid_param_choices method to return
invalid parameter choices for an IPA command.

This is needed to verify for example if userauthtype and authind are
supporting the idp value.
parent fef1bdcf
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,7 @@ import tempfile ...@@ -42,6 +42,7 @@ import tempfile
import shutil import shutil
import socket import socket
import base64 import base64
import ast
from datetime import datetime from datetime import datetime
from contextlib import contextmanager from contextlib import contextmanager
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
...@@ -1169,6 +1170,32 @@ class IPAAnsibleModule(AnsibleModule): ...@@ -1169,6 +1170,32 @@ class IPAAnsibleModule(AnsibleModule):
""" """
return api_check_param(command, name) return api_check_param(command, name)
def ipa_command_invalid_param_choices(self, command, name, value):
"""
Return invalid parameter choices for IPA command.
Parameters
----------
command: string
The IPA API command to test.
name: string
The parameter name to check.
value: string
The parameter value to verify.
"""
if command not in api.Command:
self.fail_json(msg="The command '%s' does not exist." % command)
if name not in api.Command[command].params:
self.fail_json(msg="The command '%s' does not have a parameter "
"named '%s'." % (command, name))
if not hasattr(api.Command[command].params[name], "cli_metavar"):
self.fail_json(msg="The parameter '%s' of the command '%s' does "
"not have choices." % (name, command))
_choices = ast.literal_eval(
api.Command[command].params[name].cli_metavar)
return (set(value or []) - set([""])) - set(_choices)
@staticmethod @staticmethod
def ipa_check_version(oper, requested_version): def ipa_check_version(oper, requested_version):
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment