From 64ee210c91c092743d1a5b65b6709fa192d8fea1 Mon Sep 17 00:00:00 2001
From: Thomas Woerner <twoerner@redhat.com>
Date: Fri, 16 Sep 2022 18:09:13 +0200
Subject: [PATCH] ansible_freeipa_module: Remove deprecated FreeIPABaseModule

The FreeIPABaseModule class has been maked deprecated with
ansible-freeipa version 1.5.0. It is not used in the code any more
therefore it is time to finally remove it.
---
 .../module_utils/ansible_freeipa_module.py    | 223 ------------------
 1 file changed, 223 deletions(-)

diff --git a/plugins/module_utils/ansible_freeipa_module.py b/plugins/module_utils/ansible_freeipa_module.py
index 354ed3cf..5198b92d 100644
--- a/plugins/module_utils/ansible_freeipa_module.py
+++ b/plugins/module_utils/ansible_freeipa_module.py
@@ -1270,226 +1270,3 @@ else:
                 self.fail_json(msg=", ".join(_errors))
 
             return changed
-
-    class FreeIPABaseModule(IPAAnsibleModule):
-        """
-        Base class for FreeIPA Ansible modules.
-
-        Provides methods useful methods to be used by our modules.
-
-        This class should be overriten and instantiated for the module.
-        A basic implementation of an Ansible FreeIPA module expects its
-        class to:
-
-        1. Define a class attribute ``ipa_param_mapping``
-        2. Implement the method ``define_ipa_commands()``
-        3. Implement the method ``check_ipa_params()`` (optional)
-
-        After instantiating the class the method ``ipa_run()`` should be
-        called.
-
-        Example (ansible-freeipa/plugins/modules/ipasomemodule.py):
-
-        class SomeIPAModule(FreeIPABaseModule):
-            ipa_param_mapping = {
-                "arg_to_be_passed_to_ipa_command": "module_param",
-                "another_arg": "get_another_module_param",
-            }
-
-            def get_another_module_param(self):
-                another_module_param = self.ipa_params.another_module_param
-                # Validate or modify another_module_param
-                # ...
-                return another_module_param
-
-            def check_ipa_params(self):
-                # Validate your params here
-                # Example:
-                if not self.ipa_params.module_param in VALID_OPTIONS:
-                    self.fail_json(
-                        msg="Invalid value for argument module_param")
-
-            def define_ipa_commands(self):
-                args = self.get_ipa_command_args()
-
-                self.add_ipa_command(
-                    "some_ipa_command",
-                    name="obj-name",
-                    args=args,
-                )
-
-        def main():
-            ipa_module = SomeIPAModule(argument_spec=dict(
-                module_param=dict(
-                    type="str",
-                    default=None,
-                    required=False,
-                ),
-                another_module_param=dict(
-                    type="str",
-                    default=None,
-                    required=False,
-                ),
-            ))
-            ipa_module.ipa_run()
-
-        if __name__ == "__main__":
-            main()
-
-        """
-
-        ipa_param_mapping = None
-
-        def __init__(self, *args, **kwargs):
-            # pylint: disable=super-with-arguments
-            super(FreeIPABaseModule, self).__init__(*args, **kwargs)
-
-            self.deprecate(
-                msg="FreeIPABaseModule is deprecated. Use IPAAnsibleModule.",
-                version="1.5.0"
-            )
-
-            # Status of an execution. Will be changed to True
-            #   if something is actually peformed.
-            self.changed = False
-
-            # Status of the connection with the IPA server.
-            # We need to know if the connection was actually stablished
-            #   before we start sending commands.
-            self.ipa_connected = False
-
-            # Commands to be executed
-            self.ipa_commands = []
-
-            # Module exit arguments.
-            self.exit_args = {}
-
-        def get_ipa_command_args(self, **kwargs):
-            """
-            Return a dict to be passed to an IPA command.
-
-            The keys of ``ipa_param_mapping`` are also the keys of the return
-            dict.
-
-            The values of ``ipa_param_mapping`` needs to be either:
-                * A str with the name of a defined method; or
-                * A key of ``AnsibleModule.param``.
-
-            In case of a method the return of the method will be set as value
-            for the return dict.
-
-            In case of a AnsibleModule.param the value of the param will be
-            set in the return dict. In addition to that boolean values will be
-            automaticaly converted to uppercase strings (as required by FreeIPA
-            server).
-
-            """
-            self.deprecate(
-                msg=(
-                    "FreeIPABaseModule is deprecated. Use IPAAnsibleModule. "
-                    "Use 'AnsibleFreeIPAParams.get_ipa_command_args()', "
-                    "Instantiate it using the class 'ipa_params_mapping'."
-                ),
-                version="1.5.0"
-            )
-            mapping = IPAParamMapping(self, self.ipa_param_mapping)
-            return mapping.get_ipa_command_args(**kwargs)
-
-        def check_ipa_params(self):
-            """Validate ipa_params before command is called."""
-            self.deprecate(
-                msg=(
-                    "FreeIPABaseModule is deprecated. Use IPAAnsibleModule. "
-                ),
-                version="1.5.0"
-            )
-            pass  # pylint: disable=unnecessary-pass
-
-        def define_ipa_commands(self):
-            """Define commands that will be run in IPA server."""
-            raise NotImplementedError
-
-        def add_ipa_command(self, command, name=None, args=None):
-            """Add a command to the list of commands to be executed."""
-            self.ipa_commands.append((name, command, args or {}))
-
-        def _run_ipa_commands(self):
-            """Execute commands in self.ipa_commands."""
-            self.changed = self.execute_ipa_commands(
-                self.ipa_commands,
-                result_handler=self.process_results.__func__,
-                exit_args=self.exit_args
-            )
-
-        def process_results(
-            self, result, command, name, args, exit_args
-        ):  # pylint: disable=unused-argument
-            """
-            Process an API command result.
-
-            This method must be overriden in subclasses if 'exit_args'
-            is to be modified.
-            """
-            self.deprecate(
-                msg=(
-                    "FreeIPABaseModule is deprecated. Use IPAAnsibleModule. "
-                ),
-                version="1.5.0"
-            )
-            self.process_command_result(name, command, args, result)
-
-        def process_command_result(self, _name, _command, _args, result):
-            """
-            Process an API command result.
-
-            This method can be overriden in subclasses, and
-            change self.exit_values to return data in the
-            result for the controller.
-            """
-            self.deprecate(
-                msg=(
-                    "FreeIPABaseModule is deprecated. Use IPAAnsibleModule. "
-                    "To aid in porting to IPAAnsibleModule, change to "
-                    "'FreeIPABaseModule.process_results'."
-                ),
-                version="1.5.0"
-            )
-
-            if "completed" in result:
-                if result["completed"] > 0:
-                    self.changed = True
-            else:
-                self.changed = True
-
-        def require_ipa_attrs_change(self, command_args, ipa_attrs):
-            """
-            Compare given args with current object attributes.
-
-            Returns True in case current IPA object attributes differ from
-            args passed to the module.
-            """
-            self.deprecate(
-                msg=(
-                    "FreeIPABaseModule is deprecated. Use IPAAnsibleModule. "
-                    "FreeIPABaseModule require_ipa_attrs_change() is "
-                    "deprecated. Use ansible_freeipa_module.compare_args()."
-                ),
-                version="1.5.0"
-            )
-            equal = compare_args_ipa(self, command_args, ipa_attrs)
-            return not equal
-
-        def ipa_run(self):
-            """Execute module actions."""
-            self.deprecate(
-                msg=(
-                    "FreeIPABaseModule is deprecated. Use IPAAnsibleModule."
-                ),
-                version="1.5.0"
-            )
-            ipaapi_context = self.params_get("ipaapi_context")
-            with self.ipa_connect(context=ipaapi_context):
-                self.check_ipa_params()
-                self.define_ipa_commands()
-                self._run_ipa_commands()
-            self.exit_json(changed=self.changed, **self.exit_args)
-- 
GitLab