Skip to content

Commit

Permalink
Add deprecation warning
Browse files Browse the repository at this point in the history
Signed-off-by: rohitthakur2590 <rohitthakur2590@outlook.com>
  • Loading branch information
rohitthakur2590 committed Jan 16, 2025
1 parent 2707170 commit bdf835a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
8 changes: 8 additions & 0 deletions changelogs/fragments/deprecate_parsing_filter_plugins.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
deprecated_features:
- "`parse_cli` filter plugin is deprecated and will be removed in a future release after 2027-02-01. Use `ansible.utils.cli_parse` as a replacement."
- "`parse_cli_textfsm` filter plugin is deprecated and will be removed in a future release after 2027-02-01. Use `ansible.utils.cli_parse` with the `ansible.utils.textfsm_parser` parser as a replacement."
- "`parse_xml` filter plugin is deprecated and will be removed in a future release after 2027-02-01. Use `ansible.utils.cli_parse` with the `ansible.utils.xml_parser` parser as a replacement."
- "Added deprecation warnings for the above plugins, displayed when running respective filter plugins."


11 changes: 8 additions & 3 deletions plugins/filter/parse_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- The filter plugins converts the output of a network device
CLI command into structured JSON output.
- Using the parameters below - C(xml_data | ansible.netcommon.parse_cli(template.yml))
- This plugin is deprecated and will be removed in a future release after 2027-02-01, please Use ansible.utils.cli_parse instead.
notes:
- The parse_cli filter will load the spec file and pass the command output through it,
returning JSON output. The YAML spec file defines how to parse the CLI output
Expand Down Expand Up @@ -135,17 +136,21 @@

from ansible_collections.ansible.netcommon.plugins.plugin_utils.parse_cli import parse_cli


try:
from jinja2.filters import pass_environment
except ImportError:
from jinja2.filters import environmentfilter as pass_environment
from ansible.utils.display import Display


@pass_environment
def _parse_cli(*args, **kwargs):
"""Extend vlan data"""

"""parse cli"""
display = Display()
display.warning(
"The 'parse_cli' filter is deprecated and will be removed in a future release "
"after 2027-02-01. Use 'ansible.utils.cli_parse' instead."
)
keys = ["output", "tmpl"]
data = dict(zip(keys, args[1:]))
data.update(kwargs)
Expand Down
11 changes: 8 additions & 3 deletions plugins/filter/parse_cli_textfsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- The network filters also support parsing the output of a CLI command using the TextFSM library.
To parse the CLI output with TextFSM use this filter.
- Using the parameters below - C(data | ansible.netcommon.parse_cli_textfsm(template.yml))
- This plugin is deprecated and will be removed in a future release after 2027-02-01, please Use ansible.utils.cli_parse instead.
notes:
- Use of the TextFSM filter requires the TextFSM library to be installed.
options:
Expand Down Expand Up @@ -92,17 +93,21 @@
parse_cli_textfsm,
)


try:
from jinja2.filters import pass_environment
except ImportError:
from jinja2.filters import environmentfilter as pass_environment
from ansible.utils.display import Display


@pass_environment
def _parse_cli_textfsm(*args, **kwargs):
"""Extend vlan data"""

"""parse textfsm"""
display = Display()
display.warning(
"The 'parse_cli_textfsm' filter is deprecated and will be removed in a future release "
"after 2027-02-01. Use 'ansible.utils.cli_parse' instead."
)
keys = ["value", "template"]
data = dict(zip(keys, args[1:]))
data.update(kwargs)
Expand Down
10 changes: 8 additions & 2 deletions plugins/filter/parse_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- This filter will load the spec file and pass the command output
through it, returning JSON output.
- The YAML spec file defines how to parse the CLI output.
- This plugin is deprecated and will be removed in a future release after 2027-02-01, please Use ansible.utils.cli_parse instead.
notes:
- To convert the XML output of a network device command into structured JSON output.
options:
Expand Down Expand Up @@ -166,17 +167,22 @@

from ansible_collections.ansible.netcommon.plugins.plugin_utils.parse_xml import parse_xml


try:
from jinja2.filters import pass_environment
except ImportError:
from jinja2.filters import environmentfilter as pass_environment
from ansible.utils.display import Display


@pass_environment
def _parse_xml(*args, **kwargs):
"""Extend vlan data"""
"""parse xml"""

display = Display()
display.warning(
"The 'parse_xml' filter is deprecated and will be removed in a future release "
"after 2027-02-01. Use 'ansible.utils.cli_parse' instead."
)
keys = ["output", "tmpl"]
data = dict(zip(keys, args[1:]))
data.update(kwargs)
Expand Down

0 comments on commit bdf835a

Please sign in to comment.