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_interfaces_status.textfsm throwing error when status has additional text #1938

Closed
tfchristie-wi opened this issue Dec 18, 2024 · 2 comments · Fixed by #1941
Closed

Comments

@tfchristie-wi
Copy link
Contributor

ISSUE TYPE
  • Template Issue with error and raw data
TEMPLATE USING
Value PORT (\S+)
Value NAME (.+?)
Value STATUS (err-disabled|disabled|connected|notconnect|inactive|up|down|monitoring|suspended)
Value VLAN_ID (\d+|trunk|routed|unassigned)
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_ID}\s+${DUPLEX}\s+${SPEED}\s*${TYPE}$$ -> Record
  ^\s*${PORT}\s+${NAME}\s+${STATUS}\s+${VLAN_ID}\s+${DUPLEX}\s+${SPEED}\s*${TYPE}$$ -> Record
  ^\s*${PORT}\s+${NAME}\s+${STATUS}:?\s+${VLAN_ID}\s+${DUPLEX}\s+${SPEED}\s*${TYPE}\s*$$ -> Record
  ^-+
  ^\s*$$
  ^. -> Error




SAMPLE COMMAND OUTPUT
Port         Name               Status       Vlan       Duplex  Speed Type
Gi3/0/11     asdfqwerzxcv connected    1137       a-full a-1000 10/100/1000BaseTX
Gi3/0/12     asdfqwerzxcv connected    1137       a-full a-1000 10/100/1000BaseTX
Gi3/0/13     asdfqwerzxcv connected    1137       a-full a-1000 10/100/1000BaseTX
Gi3/0/14     asdfqwerzxcv connected    1137       a-full a-1000 10/100/1000BaseTX
Gi3/0/15     asdfqwerzxcv connected    1137       a-full a-1000 10/100/1000BaseTX
Gi3/0/16     asdfqwerzxcv connected: T 1137       a-full a-1000 10/100/1000BaseTX
Gi3/0/17     asdfqwerzxcv connected    1137       a-full a-1000 10/100/1000BaseTX
Gi3/0/18     asdfqwerzxcv connected    1137       a-full a-1000 10/100/1000BaseTX


SUMMARY

https://community.cisco.com/t5/switching/cisco-9300-switch-show-interfaces-status-displays-connected-t/td-p/4591464
The colon isn't followed by just whitespace. In the example case, the status including additional text is 'connected: TDR running'.
The additional text gets truncated so the patter match is a colon following status, any char including space for the message, and a space before the VLAN field.

STEPS TO REPRODUCE
EXPECTED RESULTS
when I use the following regex in place of the line containing :?\s+:  (line 24)
  ^\s*${PORT}\s+${NAME}\s+${STATUS}:.*\s${VLAN_ID}\s+${DUPLEX}\s+${SPEED}\s*${TYPE}\s*$$ -> Record
I get what I would expect:
      "GigabitEthernet3/0/16": {
        "duplex": "auto",
        "shutdown": "false",
        "description": "asdfqwerzxcv",
        "state": "reserved",
        "port_name": "GigabitEthernet3/0/16",                                                                                   "activation_status": "on",
        "vlan": "1137",                                                                                                         "speed": "auto"
      },              

ACTUAL RESULTS
   "error": "Error processing interface output in TextFSM"
@jmcgill298
Copy link
Contributor

@tfchristie-wi are you able to put in a pull request with the fix and updated test case?

@tfchristie-wi
Copy link
Contributor Author

tfchristie-wi commented Dec 19, 2024 via email

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