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

cisco_ios_show_ip_interface.template does not deal with peer address on virtual-access interface #461

Closed
speirsoj01 opened this issue Aug 29, 2019 · 0 comments · Fixed by #495

Comments

@speirsoj01
Copy link

speirsoj01 commented Aug 29, 2019

ISSUE TYPE
  • Bug Report
TEMPLATE USING
Value Required INTF (\S+)
Value LINK_STATUS (.+?)
Value PROTOCOL_STATUS (.+?)
Value List IPADDR (\S+?)
Value List MASK (\d*)
Value VRF (\S+)
Value MTU (\d+)
Value List IP_HELPER (\d+\.\d+\.\d+\.\d+)
Value OUTGOING_ACL (.*?)
Value INBOUND_ACL (.*?)


Start
  ^\S -> Continue.Record
  ^${INTF}\s+is\s+${LINK_STATUS},\s+line\s+protocol\s+is\s+${PROTOCOL_STATUS}\s*$$
  ^\s+Internet\s+address\s+is\s+${IPADDR}/?${MASK}\s*$$
  ^\s+Secondary\s+address\s+${IPADDR}/?${MASK}\s*$$
  ^.+VPN\s+Routing/Forwarding\s+"${VRF}"
  ^\s+MTU\s+is\s+${MTU}\s+bytes
  ^\s+Helper\s+address(es|)\s(is|are)\s+${IP_HELPER}\s*$$ -> HELPERS
  ^\s+Outgoing\s+(?:Common\s+)?access\s+list\s+is\s+not\s+set
  ^\s+Outgoing\s+(?:Common\s+)?access\s+list\s+is\s+${OUTGOING_ACL}\s*$$
  ^\s+Inbound\s+(?:Common\s+)?access\s+list\s+is\s+not\s+set
  ^\s+Inbound\s+(?:Common\s+)?access\s+list\s+is\s+${INBOUND_ACL}\s*$$
  ^\s+Internet\s+protocol
  ^\s+Interface\s+is\s+unnumbered
  ^\s+Broadcast
  ^\s+Multicast
  ^\s+2[2-5]\d\.
  ^\s+Address\s+determined
  ^\s+Directed
  ^\s+MTU
  ^\s+Helper
  ^\s+Directed
  ^\s+Outgoing
  ^\s+Inbound
  ^\s+.*Proxy
  ^\s+Security
  ^\s+Split
  ^\s+ICMP
  ^\s+IP\s+(?:fast|Flow|CEF|Null|multicast|route|output|access)
  ^\s+Associated
  ^\s+Topology
  ^\s+Router
  ^\s+TCP
  ^\s+RTP
  ^\s+Probe
  ^\s+Policy
  ^\s+Network\s+address\s+
  ^\s+BGP
  ^\s+(Input|Output|Post)\s+.*features
  ^\s+IPv4\s+WCCP
  ^\s*$$
  ^. -> Error

HELPERS
  ^\s+${IP_HELPER}\s*$$
  ^\s+Directed -> Start
  ^.* -> Error
SAMPLE COMMAND OUTPUT
Virtual-Access1 is up, line protocol is up
  Internet protocol processing disabled
Virtual-Access2 is up, line protocol is up
  Peer address is 10.1.1.1
  Dialer interface is Dialer1
SUMMARY

The template file show_ip_interface for Cisco IOS does not cover all the possible options.

I did resolve this issue by adding, but not sure how you'd want to deal with this in the real code:

  ^\s+Peer address is (\d+\.\d+\.\d+\.\d+)
  ^\s+Dialer interface is Dialer(\d+)
STEPS TO REPRODUCE
output = """Virtual-Access1 is up, line protocol is up
             Internet protocol processing disabled
Virtual-Access2 is up, line protocol is up
  Peer address is 10.1.1.1
  Dialer interface is Dialer1"""
  
from ntc_templates.parse import parse_output
ip_interface = parse_output(platform="cisco_ios", command="show ip interface", data=output)
EXPECTED RESULTS

Parsed object for the output of the command.

ACTUAL RESULTS
Peer Address Error:
Traceback (most recent call last):
  File "repo.py", line 11, in <module>
    ip_interface = parse_output(platform="cisco_ios", command="show ip interface", data=output)
  File "C:\Users\ospeirs\AppData\Roaming\Python\Python37\site-packages\ntc_templates\parse.py", line 35, in parse_output
    cli_table.ParseCmd(data, attrs)
  File "C:\Users\ospeirs\AppData\Roaming\Python\Python37\site-packages\clitable.py", line 277, in ParseCmd
    self.table = self._ParseCmdItem(self.raw, template_file=template_files[0])
  File "C:\Users\ospeirs\AppData\Roaming\Python\Python37\site-packages\clitable.py", line 310, in _ParseCmdItem
    for record in fsm.ParseText(cmd_input):
  File "C:\Users\ospeirs\AppData\Roaming\Python\Python37\site-packages\textfsm.py", line 885, in ParseText
    self._CheckLine(line)
  File "C:\Users\ospeirs\AppData\Roaming\Python\Python37\site-packages\textfsm.py", line 908, in _CheckLine
    if self._Operations(rule, line):
  File "C:\Users\ospeirs\AppData\Roaming\Python\Python37\site-packages\textfsm.py", line 989, in _Operations
    % (rule.line_num, line))
textfsm.TextFSMError: State Error raised. Rule Line: 54. Input Line:   Peer address is 10.1.1.1


Dialer Error:
Traceback (most recent call last):
  File ".\repo.py", line 10, in <module>
    ip_interface = parse_output(platform="cisco_ios", command="sh ip int", data=output)
  File "C:\Users\ospeirs\AppData\Roaming\Python\Python37\site-packages\ntc_templates\parse.py", line 35, in parse_output
    cli_table.ParseCmd(data, attrs)
  File "C:\Users\ospeirs\AppData\Roaming\Python\Python37\site-packages\clitable.py", line 277, in ParseCmd
    self.table = self._ParseCmdItem(self.raw, template_file=template_files[0])
  File "C:\Users\ospeirs\AppData\Roaming\Python\Python37\site-packages\clitable.py", line 310, in _ParseCmdItem
    for record in fsm.ParseText(cmd_input):
  File "C:\Users\ospeirs\AppData\Roaming\Python\Python37\site-packages\textfsm.py", line 885, in ParseText
    self._CheckLine(line)
  File "C:\Users\ospeirs\AppData\Roaming\Python\Python37\site-packages\textfsm.py", line 908, in _CheckLine
    if self._Operations(rule, line):
  File "C:\Users\ospeirs\AppData\Roaming\Python\Python37\site-packages\textfsm.py", line 989, in _Operations
    % (rule.line_num, line))
textfsm.TextFSMError: State Error raised. Rule Line: 54. Input Line:   Dialer interface is Dialer1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants