diff --git a/changelogs/fragments/todo_condition.yml b/changelogs/fragments/todo_condition.yml new file mode 100644 index 0000000..a5fa6a2 --- /dev/null +++ b/changelogs/fragments/todo_condition.yml @@ -0,0 +1,3 @@ +--- +minor_changes: + - Removed conditional check for deprecated ansible.netcommon.cli_parse from ansible.utils.cli_parse diff --git a/plugins/action/cli_parse.py b/plugins/action/cli_parse.py index e045a89..68a02b6 100644 --- a/plugins/action/cli_parse.py +++ b/plugins/action/cli_parse.py @@ -100,19 +100,6 @@ class ActionModule(ActionBase): """ requested_parser = self._task.args.get("parser").get("name") cref = dict(zip(["corg", "cname", "plugin"], requested_parser.split("."))) - if cref["cname"] == "netcommon" and cref["plugin"] in [ - "json", - "textfsm", - "ttp", - "xml", - ]: - cref["cname"] = "utils" - msg = ( - "Use 'ansible.utils.{plugin}' for parser name instead of '{requested_parser}'." - " This feature will be removed from 'ansible.netcommon' collection in a release" - " after 2022-11-01".format(plugin=cref["plugin"], requested_parser=requested_parser) - ) - self._display.warning(msg) parserlib = "ansible_collections.{corg}.{cname}.plugins.sub_plugins.cli_parser.{plugin}_parser".format( **cref, @@ -126,33 +113,6 @@ class ActionModule(ActionBase): ) return parser except Exception as exc: - # TODO: The condition is added to support old sub-plugin structure. - # Remove the if condition after ansible.netcommon.cli_parse module is removed - # from ansible.netcommon collection - if cref["cname"] == "netcommon" and cref["plugin"] in [ - "native", - "content_templates", - "ntc", - "pyats", - ]: - parserlib = ( - "ansible_collections.{corg}.{cname}.plugins.cli_parsers.{plugin}_parser".format( - **cref, - ) - ) - try: - parsercls = getattr(import_module(parserlib), self.PARSER_CLS_NAME) - parser = parsercls( - task_args=self._task.args, - task_vars=task_vars, - debug=self._debug, - ) - return parser - except Exception as exc: - self._result["failed"] = True - self._result["msg"] = "Error loading parser: {err}".format(err=to_native(exc)) - return None - self._result["failed"] = True self._result["msg"] = "Error loading parser: {err}".format(err=to_native(exc)) return None