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

show int status returns error (seems template error) for particular switch for other switches it does work (iOS). #922

Closed
kaspervbrakel opened this issue Apr 21, 2021 · 1 comment · Fixed by #928
Assignees

Comments

@kaspervbrakel
Copy link

kaspervbrakel commented Apr 21, 2021

ISSUE TYPE
  • Bug Report
TEMPLATE USING
cat cisco_ios_show_interfaces_status.textfsm
Value PORT (\S+)
Value NAME (.+?)
Value STATUS (err-disabled|disabled|connected|notconnect|inactive|up|down)
Value VLAN (\S+)
Value DUPLEX (\S+)
Value SPEED (\S+)
Value TYPE (.*)
Value FC_MODE (\S+)

Start
  ^Load\s+for\s+
  # Capture time-stamp if vty line has command time-stamping turned on
  ^Time\s+source\s+is
  ^-+\s*$$
  ^Port\s+Name\s+Status\s+Vlan\s+Duplex\s+Speed\s+Type -> Interfaces
  ^\s*$$
  ^. -> Error

Interfaces
  #Match fc...
  ^\s*${PORT}\s+is\s+${STATUS}\s+Port\s+mode\s+is\s+${FC_MODE}\s*$$ -> Record
  ^\s*${PORT}\s+is\s+${STATUS}\s+\(${TYPE}\)\s*$$ -> Record
  ^\s*${PORT}\s+${STATUS}\s+${VLAN}\s+${DUPLEX}\s+${SPEED}\s*${TYPE}$$ -> Record
  ^\s*${PORT}\s+${NAME}\s+${STATUS}\s+${VLAN}\s+${DUPLEX}\s+${SPEED}\s*${TYPE}$$ -> Record
  ^-+
  ^\s*$$
  ^. -> Error
SAMPLE COMMAND OUTPUT

On Ios version:

Cisco IOS Software, s2t54 Software (s2t54-IPBASEK9_NPE-M), Version 15.1(2)SY, RELEASE SOFTWARE (fc4)

SH module:

Mod Ports Card Type                              Model              Serial No.
--- ----- -------------------------------------- ------------------ -----------
  1   48  CEF720 48 port 10/100/1000mb Ethernet  WS-X6848-GE-TX     
  2   48  CEF720 48 port 10/100/1000mb Ethernet  WS-X6848-GE-TX     
  5   48  CEF720 48 port 10/100/1000mb Ethernet  WS-X6848-GE-TX     
  7    5  Supervisor Engine 2T 10GE w/ CTS (Acti VS-SUP2T-10G       
  9   16  CEF720 16 port 10GE                    WS-X6816-10GE      
 11   24  CEF720 24 port 1000mb SFP              WS-X6824-SFP       
 12   24  CEF720 24 port 1000mb SFP              WS-X6824-SFP       
SUMMARY

python code:
conn.send_command('sh int status', use_textfsm=True)

EXPECTED RESULTS

for other switches same code does work and returns sh int status output.

snippet from int status:

Gi2/2/18      <<< UNUSED >>>     disabled     routed       auto   auto 10/100/1000BaseT
Gi2/2/19      <<< UNUSED >>>     disabled     routed       auto   auto 10/100/1000BaseT
Gi2/2/20      <<< UNUSED >>>     disabled     routed       auto   auto 10/100/1000BaseT
Gi2/2/21      <<< UNUSED >>>     disabled     routed       auto   auto 10/100/1000BaseT
Gi2/2/22      <<< UNUSED >>>     disabled     routed       auto   auto 10/100/1000BaseT
Gi2/2/23      <<< UNUSED >>>     disabled     routed       auto   auto 10/100/1000BaseT
Gi2/2/24      <<< UNUSED >>>     disabled     routed       auto   auto 10/100/1000BaseT
Gi2/2/25      <<< UNUSED >>>     disabled     routed       auto   auto 10/100/1000BaseT
Gi2/2/26      <<< UNUSED >>>     disabled     1            auto   auto 10/100/1000BaseT
Gi2/2/27      <<< UNUSED >>>     disabled     1            auto   auto 10/100/1000BaseT
Gi2/2/28      <<< UNUSED >>>     disabled     1            auto   auto 10/100/1000BaseT
ACTUAL RESULTS
Traceback (most recent call last):
  File "OT_Hosting.py", line 217, in <module>
    main()
  File "OT_Hosting.py", line 61, in main
    retrieveData(config, openConnection("cisco_ios", config["location"]+"-I-"+name, config["username"], password), name)
  File "OT_Hosting.py", line 67, in retrieveData
    int_status_dict = getIntStatus(conn.send_command('sh int status', use_textfsm=True))  #gives problems SW001 bealt01
  File "/home/GDS/brakek01/.local/lib/python3.6/site-packages/netmiko/utilities.py", line 347, in wrapper_decorator
    return func(self, *args, **kwargs)
  File "/home/GDS/brakek01/.local/lib/python3.6/site-packages/netmiko/base_connection.py", line 1448, in send_command
    template=textfsm_template,
  File "/home/GDS/brakek01/.local/lib/python3.6/site-packages/netmiko/utilities.py", line 280, in get_structured_data
    return _textfsm_parse(textfsm_obj, raw_output, attrs)
  File "/home/GDS/brakek01/.local/lib/python3.6/site-packages/netmiko/utilities.py", line 252, in _textfsm_parse
    textfsm_obj.ParseCmd(raw_output, attrs)
  File "/home/GDS/brakek01/.local/lib/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/GDS/brakek01/.local/lib/python3.6/site-packages/netmiko/_textfsm/_clitable.py", line 303, in _ParseCmdItem
    for record in fsm.ParseText(cmd_input):
  File "/home/GDS/brakek01/.local/lib/python3.6/site-packages/textfsm/parser.py", line 895, in ParseText
    self._CheckLine(line)
  File "/home/GDS/brakek01/.local/lib/python3.6/site-packages/textfsm/parser.py", line 944, in _CheckLine
    if self._Operations(rule, line):
  File "/home/GDS/brakek01/.local/lib/python3.6/site-packages/textfsm/parser.py", line 1025, in _Operations
    % (rule.line_num, line))
textfsm.parser.TextFSMError: State Error raised. Rule Line: 27. Input Line: Gi2/2/6       <<< UNUSED >>>     monitoring   routed     a-full a-1000 10/100/1000BaseT
@kaspervbrakel
Copy link
Author

kaspervbrakel commented Apr 21, 2021

Hi,

I actually found the issue. Please add monitoring to STATUS values:
Value STATUS (err-disabled|disabled|connected|notconnect|inactive|up|down|monitoring)

port output:
Gi2/2/6 <<< UNUSED >>> monitoring routed a-full a-1000 10/100/1000BaseT

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 a pull request may close this issue.

2 participants