Skip to content

Commit

Permalink
Deprecate Parser filter plugins (#682)
Browse files Browse the repository at this point in the history
* Add deprecation warning

Signed-off-by: rohitthakur2590 <rohitthakur2590@outlook.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Signed-off-by: rohitthakur2590 <rohitthakur2590@outlook.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
rohitthakur2590 and pre-commit-ci[bot] authored Jan 17, 2025
1 parent 2707170 commit 3185a94
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 5 deletions.
6 changes: 6 additions & 0 deletions changelogs/fragments/deprecate_parsing_filter_plugins.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
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."
1 change: 1 addition & 0 deletions docs/ansible.netcommon.parse_cli_filter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Synopsis
--------
- The filter plugins converts the output of a network device CLI command into structured JSON output.
- Using the parameters below - ``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.



Expand Down
1 change: 1 addition & 0 deletions docs/ansible.netcommon.parse_cli_textfsm_filter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Synopsis
--------
- 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 - ``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.



Expand Down
1 change: 1 addition & 0 deletions docs/ansible.netcommon.parse_xml_filter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Synopsis
--------
- 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.



Expand Down
11 changes: 9 additions & 2 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 @@ -141,11 +142,17 @@
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: 9 additions & 2 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 @@ -98,11 +99,17 @@
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: 9 additions & 1 deletion 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 @@ -172,11 +173,18 @@
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 3185a94

Please sign in to comment.