From 1f7e0bc422c5c36f958d565b11c7fbbab538489e Mon Sep 17 00:00:00 2001 From: Alexei Znamensky Date: Sat, 15 Oct 2022 22:12:00 +1300 Subject: [PATCH 1/3] MH CmdModuleHelper: deprecation --- plugins/module_utils/mh/mixins/cmd.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plugins/module_utils/mh/mixins/cmd.py b/plugins/module_utils/mh/mixins/cmd.py index da2629f9fea..6b0262168c4 100644 --- a/plugins/module_utils/mh/mixins/cmd.py +++ b/plugins/module_utils/mh/mixins/cmd.py @@ -34,6 +34,10 @@ def deco(f): def __init__(self, name, fmt=None, style=FORMAT, stars=0): """ + THIS CLASS IS BEING DEPRECATED. + It was never meant to be used outside the scope of CmdMixin, and CmdMixin is being deprecated. + See the deprecation notice in CmdMixin.__init__() below. + Creates a CLI-formatter for one specific argument. The argument may be a module parameter or just a named parameter for the CLI command execution. :param name: Name of the argument to be formatted @@ -110,6 +114,15 @@ def custom_formats(self): result[param] = ArgFormat(param, **fmt_spec) return result + def __init__(self, *args, **kwargs): + super(CmdMixin, self).__init__(*args, **kwargs) + self.module.deprecate( + 'The CmdMixin used in classes CmdModuleHelper and CmdStateModuleHelper is being deprecated. ' + 'Modules should use community.general.plugins.module_utils.cmd_runner.CmdRunner instead.', + version='8.0.0', + collection_name='community.general', + ) + def _calculate_args(self, extra_params=None, params=None): def add_arg_formatted_param(_cmd_args, arg_format, _value): args = list(arg_format.to_text(_value)) From 94023244570421a808c3927c7c262da4b14e8474 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky Date: Sat, 15 Oct 2022 22:26:58 +1300 Subject: [PATCH 2/3] add changelog fragment --- changelogs/fragments/5370-mh-cmdmixin-deprecation.yaml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelogs/fragments/5370-mh-cmdmixin-deprecation.yaml diff --git a/changelogs/fragments/5370-mh-cmdmixin-deprecation.yaml b/changelogs/fragments/5370-mh-cmdmixin-deprecation.yaml new file mode 100644 index 00000000000..4c4273358aa --- /dev/null +++ b/changelogs/fragments/5370-mh-cmdmixin-deprecation.yaml @@ -0,0 +1,5 @@ +deprecated_features: + - CmdMixin module utils - deprecated in favor of the ``CmdRunner`` module util (https://github.com/ansible-collections/community.general/pull/5370). + - CmdModuleHelper module utils - deprecated in favor of the ``CmdRunner`` module util (https://github.com/ansible-collections/community.general/pull/5370). + - CmdStateModuleHelper module utils - deprecated in favor of the ``CmdRunner`` module util (https://github.com/ansible-collections/community.general/pull/5370). + - ArgFormat module utils - deprecated along ``CmdMixin``, in favor of the ``cmd_runner_fmt`` module util (https://github.com/ansible-collections/community.general/pull/5370). From 0221cb10ecce83de70600d8f1c35286964d4d70c Mon Sep 17 00:00:00 2001 From: Alexei Znamensky Date: Tue, 18 Oct 2022 21:41:12 +1300 Subject: [PATCH 3/3] add deprecation comments in many parts of the code --- plugins/module_utils/mh/mixins/cmd.py | 5 ++++- plugins/module_utils/mh/module_helper.py | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/module_utils/mh/mixins/cmd.py b/plugins/module_utils/mh/mixins/cmd.py index 6b0262168c4..a7d3793949f 100644 --- a/plugins/module_utils/mh/mixins/cmd.py +++ b/plugins/module_utils/mh/mixins/cmd.py @@ -36,7 +36,7 @@ def __init__(self, name, fmt=None, style=FORMAT, stars=0): """ THIS CLASS IS BEING DEPRECATED. It was never meant to be used outside the scope of CmdMixin, and CmdMixin is being deprecated. - See the deprecation notice in CmdMixin.__init__() below. + See the deprecation notice in ``CmdMixin.__init__()`` below. Creates a CLI-formatter for one specific argument. The argument may be a module parameter or just a named parameter for the CLI command execution. @@ -92,6 +92,9 @@ def to_text(self, value): class CmdMixin(object): """ + THIS CLASS IS BEING DEPRECATED. + See the deprecation notice in ``CmdMixin.__init__()`` below. + Mixin for mapping module options to running a CLI command with its arguments. """ command = None diff --git a/plugins/module_utils/mh/module_helper.py b/plugins/module_utils/mh/module_helper.py index 4251285751f..79b6f487528 100644 --- a/plugins/module_utils/mh/module_helper.py +++ b/plugins/module_utils/mh/module_helper.py @@ -84,8 +84,16 @@ class StateModuleHelper(StateMixin, ModuleHelper): class CmdModuleHelper(CmdMixin, ModuleHelper): + """ + THIS CLASS IS BEING DEPRECATED. + See the deprecation notice in ``CmdMixin.__init__()``. + """ pass class CmdStateModuleHelper(CmdMixin, StateMixin, ModuleHelper): + """ + THIS CLASS IS BEING DEPRECATED. + See the deprecation notice in ``CmdMixin.__init__()``. + """ pass