Skip to content

Commit 3185a94

Browse files
Deprecate Parser filter plugins (#682)
* Add deprecation warning Signed-off-by: rohitthakur2590 <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: rohitthakur2590 <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 2707170 commit 3185a94

7 files changed

+36
-5
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
deprecated_features:
3+
- "`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."
4+
- "`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."
5+
- "`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."
6+
- "Added deprecation warnings for the above plugins, displayed when running respective filter plugins."

docs/ansible.netcommon.parse_cli_filter.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Synopsis
1919
--------
2020
- The filter plugins converts the output of a network device CLI command into structured JSON output.
2121
- Using the parameters below - ``xml_data | ansible.netcommon.parse_cli(template.yml``)
22+
- This plugin is deprecated and will be removed in a future release after 2027-02-01, please Use ansible.utils.cli_parse instead.
2223

2324

2425

docs/ansible.netcommon.parse_cli_textfsm_filter.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Synopsis
1919
--------
2020
- 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.
2121
- Using the parameters below - ``data | ansible.netcommon.parse_cli_textfsm(template.yml``)
22+
- This plugin is deprecated and will be removed in a future release after 2027-02-01, please Use ansible.utils.cli_parse instead.
2223

2324

2425

docs/ansible.netcommon.parse_xml_filter.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Synopsis
1919
--------
2020
- This filter will load the spec file and pass the command output through it, returning JSON output.
2121
- The YAML spec file defines how to parse the CLI output.
22+
- This plugin is deprecated and will be removed in a future release after 2027-02-01, please Use ansible.utils.cli_parse instead.
2223

2324

2425

plugins/filter/parse_cli.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- The filter plugins converts the output of a network device
2323
CLI command into structured JSON output.
2424
- Using the parameters below - C(xml_data | ansible.netcommon.parse_cli(template.yml))
25+
- This plugin is deprecated and will be removed in a future release after 2027-02-01, please Use ansible.utils.cli_parse instead.
2526
notes:
2627
- The parse_cli filter will load the spec file and pass the command output through it,
2728
returning JSON output. The YAML spec file defines how to parse the CLI output
@@ -141,11 +142,17 @@
141142
except ImportError:
142143
from jinja2.filters import environmentfilter as pass_environment
143144

145+
from ansible.utils.display import Display
146+
144147

145148
@pass_environment
146149
def _parse_cli(*args, **kwargs):
147-
"""Extend vlan data"""
148-
150+
"""parse cli"""
151+
display = Display()
152+
display.warning(
153+
"The 'parse_cli' filter is deprecated and will be removed in a future release "
154+
"after 2027-02-01. Use 'ansible.utils.cli_parse' instead."
155+
)
149156
keys = ["output", "tmpl"]
150157
data = dict(zip(keys, args[1:]))
151158
data.update(kwargs)

plugins/filter/parse_cli_textfsm.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- The network filters also support parsing the output of a CLI command using the TextFSM library.
2323
To parse the CLI output with TextFSM use this filter.
2424
- Using the parameters below - C(data | ansible.netcommon.parse_cli_textfsm(template.yml))
25+
- This plugin is deprecated and will be removed in a future release after 2027-02-01, please Use ansible.utils.cli_parse instead.
2526
notes:
2627
- Use of the TextFSM filter requires the TextFSM library to be installed.
2728
options:
@@ -98,11 +99,17 @@
9899
except ImportError:
99100
from jinja2.filters import environmentfilter as pass_environment
100101

102+
from ansible.utils.display import Display
103+
101104

102105
@pass_environment
103106
def _parse_cli_textfsm(*args, **kwargs):
104-
"""Extend vlan data"""
105-
107+
"""parse textfsm"""
108+
display = Display()
109+
display.warning(
110+
"The 'parse_cli_textfsm' filter is deprecated and will be removed in a future release "
111+
"after 2027-02-01. Use 'ansible.utils.cli_parse' instead."
112+
)
106113
keys = ["value", "template"]
107114
data = dict(zip(keys, args[1:]))
108115
data.update(kwargs)

plugins/filter/parse_xml.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- This filter will load the spec file and pass the command output
2323
through it, returning JSON output.
2424
- The YAML spec file defines how to parse the CLI output.
25+
- This plugin is deprecated and will be removed in a future release after 2027-02-01, please Use ansible.utils.cli_parse instead.
2526
notes:
2627
- To convert the XML output of a network device command into structured JSON output.
2728
options:
@@ -172,11 +173,18 @@
172173
except ImportError:
173174
from jinja2.filters import environmentfilter as pass_environment
174175

176+
from ansible.utils.display import Display
177+
175178

176179
@pass_environment
177180
def _parse_xml(*args, **kwargs):
178-
"""Extend vlan data"""
181+
"""parse xml"""
179182

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

0 commit comments

Comments
 (0)