Cisco IOS. sh ip interface - textfsm.parser.TextFSMError: State Error raised.
Closed this issue · 7 comments
ISSUE TYPE
- Bug Report
TEMPLATE USING
cisco_ios_show_ip_interface.textfsm
Value Required INTERFACE (\S+)
Value LINK_STATUS (.+?)
Value PROTOCOL_STATUS (.+?)
Value List IP_ADDRESS (\S+?)
Value List PREFIX_LENGTH (\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
^${INTERFACE}\s+is\s+${LINK_STATUS},\s+line\s+protocol\s+is\s+${PROTOCOL_STATUS}\s*$$
^\s+Internet\s+address\s+is\s+${IP_ADDRESS}/?${PREFIX_LENGTH}\s*$$
^\s+Internet\s+address\s+will\s+be\s+negotiated
^\s+Secondary\s+address\s+${IP_ADDRESS}/?${PREFIX_LENGTH}\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+Peer\s+address
^\s+Dialer
^\s+Broadcast
^\s+Multicast
^\s+2[2-5]\d\.
^\s+Address\s+determined
^\s+Peer
^\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+Downstream
^\s+Associated
^\s+Topology
^\s+Router
^\s+TCP
^\s+RTP
^\s+Probe
^\s+Policy
^\s+Network\s+address\s+
^\s+BGP
^\s+Sampled\s+Netflow
^\s+IP\s+(Routed|Bridged)\s+Flow
^\s+(Input|Output|Post)\s+.*features
^\s+(IPv4\s+)?WCCP
^\s+IP\s+verify\s+source\s+reachable
^\s+\d+\s+(suppressed\s+)?verification\s+drop(s)?
^\s*IP\s+Distributed\s+switching\s+is
^\s*$$
# Capture time-stamp if vty line has command time-stamping turned on
^Load\s+for\s+
^Time\s+source\s+is
^. -> Error
HELPERS
^\s+${IP_HELPER}\s*$$
^\s+Directed -> Start
^.* -> Error
SAMPLE COMMAND OUTPUT
GigabitEthernet0/0/0 is up, line protocol is up
Internet address is 10.1.1.1/30
Broadcast address is 255.255.255.255
Address determined by non-volatile memory
MTU is 1500 bytes
Helper address is not set
Directed broadcast forwarding is disabled
Outgoing Common access list is not set
Outgoing access list is not set
Inbound Common access list is not set
Inbound access list is not set
Proxy ARP is enabled
Local Proxy ARP is disabled
Security level is default
Split horizon is enabled
ICMP redirects are always sent
ICMP unreachables are always sent
ICMP mask replies are never sent
IP fast switching is enabled
IP Flow switching is disabled
IP CEF switching is enabled
IP CEF switching turbo vector
IP Null turbo vector
Associated unicast routing topologies:
Topology "base", operation state is UP
IP multicast fast switching is enabled
IP multicast distributed fast switching is disabled
IP route-cache flags are Fast, CEF
Router Discovery is disabled
IP output packet accounting is disabled
IP access violation accounting is disabled
TCP/IP header compression is disabled
RTP/IP header compression is disabled
Probe proxy name replies are disabled
Policy routing is disabled
Network address translation is disabled
BGP Policy Mapping is disabled
Input features: Virtual Fragment Reassembly, IPSec input classification, MCI Check
Output features: IPSec output classification, IPSec: to crypto engine, Post-encryption output features
IPv4 WCCP Redirect outbound is disabled
IPv4 WCCP Redirect inbound is disabled
IPv4 WCCP Redirect exclude is disabled
IP Clear Dont Fragment is disabled
SUMMARY
When attempting to parse the output from the sh ip interface (show ip interface) command on Cisco IOS, the Error raised as shown below
STEPS TO REPRODUCE
from ntc_templates.parse import parse_output
data_parsed = parse_output(
... platform="cisco_ios", command="show ip interface", data=open('cisco_ios_show_ip_interface.raw').read())
EXPECTED RESULTS
>>> data_parsed = parse_output(
... platform="cisco_ios", command="show ip interface", data=open('cisco_ios_show_ip_interface.raw').read())
>>> data_parsed
[{'interface': 'GigabitEthernet0/0/0', 'link_status': 'up', 'protocol_status': 'up', 'ip_address': ['10.1.1.1'], 'prefix_length': ['30'], 'vrf': '', 'mtu': '1500', 'ip_helper': [], 'outgoing_acl': '', 'inbound_acl': ''}]
ACTUAL RESULTS
Traceback (most recent call last):
File "/opt/netbox_filler/715_sh_ip_int_basic_analysis_all.py", line 272, in <module>
pretty, errors = gathered_to_pretty_dict(norm_gathered)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox_filler/715_sh_ip_int_basic_analysis_all.py", line 134, in gathered_to_pretty_dict
result = cisco_iosxe_to_pretty_dict(elem)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/netbox_filler/715_sh_ip_int_basic_analysis_all.py", line 150, in cisco_iosxe_to_pretty_dict
result['interfaces'] = parse_output(platform="cisco_ios", command="show ip interface", data=device_gathered['show ip interface'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/netdevops/.local/lib/python3.11/site-packages/ntc_templates/parse.py", line 56, in parse_output
cli_table.ParseCmd(data, attrs)
File "/home/netdevops/.local/lib/python3.11/site-packages/textfsm/clitable.py", line 282, in ParseCmd
self.table = self._ParseCmdItem(self.raw, template_file=template_files[0])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/netdevops/.local/lib/python3.11/site-packages/textfsm/clitable.py", line 315, in _ParseCmdItem
for record in fsm.ParseText(cmd_input):
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/netdevops/.local/lib/python3.11/site-packages/textfsm/parser.py", line 897, in ParseText
self._CheckLine(line)
File "/home/netdevops/.local/lib/python3.11/site-packages/textfsm/parser.py", line 946, in _CheckLine
if self._Operations(rule, line):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/netdevops/.local/lib/python3.11/site-packages/textfsm/parser.py", line 1026, in _Operations
raise TextFSMError('State Error raised. Rule Line: %s. Input Line: %s'
textfsm.parser.TextFSMError: State Error raised. Rule Line: 67. Input Line: IP Clear Dont Fragment is disabled
Fix PR:
#1533
Tested, works
Same issue for me and your PR @mncrftfrcnm fixed it. Thanks for your contribution!
Same issue for me and your PR @mncrftfrcnm fixed it. Thanks for your contribution!
Thanks, @angely-dev, you're welcome,
Hope that this comment will speed up the merge :)
It's working well now. I appreciate the fix you've made. Thank you!
It's working well now. I appreciate the fix you've made. Thank you!
you're welcome :) hope the merge will happen one day
Same issue here
textfsm.parser.TextFSMError: State Error raised. Rule Line: 143. Input Line: IP Clear Dont Fragment is disabled
Thanks @goodNETnick , @angely-dev , @nobodytao, @jvanderaa for your feedback.
As the pull request has been successfully merged, I'm closing this issue.
Have a good day!