Skip to content

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

@vv0bbLeS

Description

@vv0bbLeS

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions