Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BugFix: cisco_ios show ip ospf database router and network: Make leading spaces optional #650

Merged
merged 1 commit into from
Apr 15, 2020

Conversation

ariesgeek
Copy link
Contributor

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT

cisco_ios_show_ip_ospf_database_router.textfsm
cisco_ios_show_ip_ospf_database_network.textfsm

Cisco IOS

show ip ospf database router
show ip ospf database network

SUMMARY

Fixes #649

When entered manually via the Cisco IOS CLI, these commands contain leading spaces, but when the command is issued via automated means, such as Netmiko, leading spaces are typically truncated.

Prior to this commit, the command output would match the template only if one or more space characters preceded the OSPF Router with ID heading.

This commit ensures that the command output is matched whether the leading space characters are truncated or left intact.

Resolves the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/me/.venv/lib64/python3.6/site-packages/netmiko/utilities.py", line 347, in wrapper_decorator
    return func(self, *args, **kwargs)
  File "/home/me/.venv/lib64/python3.6/site-packages/netmiko/base_connection.py", line 1447, in send_command
    template=textfsm_template,
  File "/home/me/.venv/lib64/python3.6/site-packages/netmiko/utilities.py", line 280, in get_structured_data
    return _textfsm_parse(textfsm_obj, raw_output, attrs)
  File "/home/me/.venv/lib64/python3.6/site-packages/netmiko/utilities.py", line 252, in _textfsm_parse
    textfsm_obj.ParseCmd(raw_output, attrs)
  File "/home/me/.venv/lib64/python3.6/site-packages/netmiko/_textfsm/_clitable.py", line 272, in ParseCmd
    self.table = self._ParseCmdItem(self.raw, template_file=template_files[0])
  File "/home/me/.venv/lib64/python3.6/site-packages/netmiko/_textfsm/_clitable.py", line 303, in _ParseCmdItem
    for record in fsm.ParseText(cmd_input):
  File "/home/me/.venv/lib64/python3.6/site-packages/textfsm/parser.py", line 895, in ParseText
    self._CheckLine(line)
  File "/home/me/.venv/lib64/python3.6/site-packages/textfsm/parser.py", line 944, in _CheckLine
    if self._Operations(rule, line):
  File "/home/me/.venv/lib64/python3.6/site-packages/textfsm/parser.py", line 1025, in _Operations
    % (rule.line_num, line))
textfsm.parser.TextFSMError: State Error raised. Rule Line: 23. Input Line: OSPF Router with ID (10.10.10.10) (Process ID 1)

Cisco IOS: `show ip ospf database router` and `show ip ospf database network`

When entered manually via the Cisco IOS CLI, these commands contain
leading spaces, but when the command is issued via automated means, such
as `Netmiko`, leading spaces are typically truncated.

Prior to this commit, the command output would match the template only
if one or more space characters preceded the `OSPF Router with ID`
heading.

This commit ensures that the command output is matched whether the
leading space characters are truncated or left intact.

Resolves: #649
@FragmentedPacket FragmentedPacket merged commit 5a6253b into networktocode:master Apr 15, 2020
@FragmentedPacket
Copy link
Contributor

Thanks very much for this PR. It's your first contribution to our repo and it was extremely detailed and we greatly appreciate it!

thomasblass pushed a commit to thomasblass/ntc-templates that referenced this pull request Oct 25, 2020
guillaume-mbali pushed a commit to unyc-io/ntc-templates that referenced this pull request Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Beginning of output for cisco_ios "show ip ospf database <lsa-type>" may or may not be a space character
2 participants