Removed conditional check for deprecated ansible.netcommon.cli_parse (#362)
* Removed conditional check for deprecated ansible.netcommon.cli_parse * remove warning when using netcommon parserpull/361/head
parent
6c1c3a4b81
commit
db14f96453
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
minor_changes:
|
||||||
|
- Removed conditional check for deprecated ansible.netcommon.cli_parse from ansible.utils.cli_parse
|
|
@ -100,19 +100,6 @@ class ActionModule(ActionBase):
|
||||||
"""
|
"""
|
||||||
requested_parser = self._task.args.get("parser").get("name")
|
requested_parser = self._task.args.get("parser").get("name")
|
||||||
cref = dict(zip(["corg", "cname", "plugin"], requested_parser.split(".")))
|
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(
|
parserlib = "ansible_collections.{corg}.{cname}.plugins.sub_plugins.cli_parser.{plugin}_parser".format(
|
||||||
**cref,
|
**cref,
|
||||||
|
@ -126,33 +113,6 @@ class ActionModule(ActionBase):
|
||||||
)
|
)
|
||||||
return parser
|
return parser
|
||||||
except Exception as exc:
|
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["failed"] = True
|
||||||
self._result["msg"] = "Error loading parser: {err}".format(err=to_native(exc))
|
self._result["msg"] = "Error loading parser: {err}".format(err=to_native(exc))
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in New Issue