google / google/textfsm

Enhancement - Cisco - add support for if a VRF does not exist

Open
#136 2 comments 0 reactions 0 assignees View on GitHub
help wanted wontfix
Dominant language
Python
Stars
1.2k
Forks
194
PR merge metrics
No merged PRs in 30d

Description

My current TextFSM version: `2.1.0`
My current ntc-templates version: `8.0.0`

Many Cisco switches have commands with a `vrf` parameter, such as `show ip arp` or `show ip route` , and if you pass a VRF that doesn't exist on the switch, the switch will let you know:

```
Switch1#show ip arp vrf CAMERAS
% VRF CAMERAS does not exist.
Switch1#
Switch1#
Switch1#show ip route vrf CAMERAS
% IP routing table vrf CAMERAS does not exist
Switch1#
```

However, these output lines of the VRF not existing are not supported in TextFSM `2.1.0`, and results in an error:

```
File "C:\Users\JohnDoe\AppData\Local\Programs\Python\Python313\Lib\site-packages\textfsm\clitable.py", line 278, in ParseCmd
self.table = self._ParseCmdItem(self.raw, template_file=template_files[0])
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\JohnDoe\AppData\Local\Programs\Python\Python313\Lib\site-packages\textfsm\clitable.py", line 312, in _ParseCmdItem
for record in fsm.ParseText(cmd_input):
~~~~~~~~~~~~~^^^^^^^^^^^
File "C:\Users\JohnDoe\AppData\Local\Programs\Python\Python313\Lib\site-packages\textfsm\parser.py", line 912, in ParseText
self._CheckLine(line)
~~~~~~~~~~~~~~~^^^^^^
File "C:\Users\JohnDoe\AppData\Local\Programs\Python\Python313\Lib\site-packages\textfsm\parser.py", line 961, in _CheckLine
if self._Operations(rule, line):
~~~~~~~~~~~~~~~~^^^^^^^^^^^^
File "C:\Users\JohnDoe\AppData\Local\Programs\Python\Python313\Lib\site-packages\textfsm\parser.py", line 1043, in _Operations
raise TextFSMError(
...<2 lines>...
)
textfsm.parser.TextFSMError: State Error raised. Rule Line: 15. Input Line: % VRF CAMERAS does not exist.
```

Can we add support to handle this switch output if a given VRF does not exist on a switch? The outputs seem to all carry the string `vrf [x] does not exist.`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.