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_interface_link template breaks when there are subinterfaces #1605

Open
brianatlarge opened this issue Jan 22, 2024 · 3 comments

Comments

@brianatlarge
Copy link

ISSUE TYPE
  • Template Issue with error and raw data
TEMPLATE USING
Value PORT ([a-zA-Z]{2,3}[0-9]{1,2}\/[0-9]{1,2}(\/[0-9]{1,2})?)
Value NAME (.+?)
Value DOWNTIME ((00:00:00)|(([0-9]{1,2} year[s]? , )?([0-9]{1,2} week[s]?, )?([0-9]{1,2} day[s]?, )?([0-9]{1,2} hour[s]?, )?([0-9]{1,2} minute[s]? )?([0-9]{1,2} secs))|((([0-9]{1,2}y)?([0-9]{1,2}w)?([0-9]{1,2}d)([0-9]{1,2}h)?|[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2})))
Value SINCE (.+?)
Value UPTIME ((([0-9]{1,2}m)?([0-9]{1,2}w)?([0-9]{1,2}d)|[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}))

Start
  ^\s*\^\s* -> EOF
  ^.*Invalid input detected.* -> EOF
  ^Load\s+for\s+
  # Capture time-stamp if vty line has command time-stamping turned on
  ^Time\s+source\s+is
  ^-+\s*$$
  ^\s*Port\s+Name\s+Down Time\s+Down Since\s*$$ -> DownSince
  ^\s*Port\s+Name\s+Down Time\s+Up Time\s*$$ -> UpTime
  ^\s*$$
  ^. -> Error

DownSince
  ^\s*${PORT}\s+${DOWNTIME}\s*$$ -> Record
  ^\s*${PORT}\s+${DOWNTIME}\s*${SINCE}\s*$$ -> Record
  ^\s*${PORT}\s+${NAME}\s*${DOWNTIME}\s*$$ -> Record
  ^\s*${PORT}\s+${NAME}\s*${DOWNTIME}\s+${SINCE}\s*$$ -> Record
  ^\s*$$
  ^. -> Error

UpTime
  ^\s*${PORT}\s+${NAME}\s+00:00:00\s+${UPTIME}?\s*$$ -> Record
  ^\s*${PORT}\s+${DOWNTIME}\s+${UPTIME}?\s*$$ -> Record
  ^\s*${PORT}\s+${NAME}\s+${DOWNTIME}\s*$$ -> Record
  ^\s*$$
  ^. -> Error
SAMPLE COMMAND OUTPUT
Te5/0/1                           43w5d
Te5/0/2                           43w5d
Te5/0/3                           43w5d
Te5/0/4                           43w5d
Te5/0/5                           43w5d
Te5/0/6                           43w5d
Te5/0/7                           43w5d
Te5/0/8                           43w5d
Fo5/0/9                           43w5d
Fo5/0/10                          43w5d
Twe5/0/1       L3 Link            00:00:00       9w4d
Twe5/0/1.602   L3 Link VR 00:00:00       9w4d
Twe5/0/1.603   L3 Link VRF    00:00:00       9w4d
Twe5/0/5                          43w5d
Ap5/0/1                           43w5d
Te6/0/1                           43w5d
Te6/0/2                           43w5d
Te6/0/3                           43w5d
Te6/0/4                           43w5d
Te6/0/5                           43w5d
Te6/0/6                           43w5d
Te6/0/7                           43w5d
Te6/0/8                           43w5d
Fo6/0/9                           43w5d
Fo6/0/10                          43w5d
Twe6/0/1       L3 Link            00:00:00       9w4d
Twe6/0/1.602   L3 Link VR 00:00:00       9w4d
Twe6/0/1.603   L3 Link VRF    00:00:00       9w4d
Twe6/0/5                          43w5d
SUMMARY

When subinterfaces are present, the subinterface is not included in the second group for the regex match for port information

STEPS TO REPRODUCE
EXPECTED RESULTS

results =
{'downtime': '',
'name': 'L3 Link',
'port': 'Te6/0/1',
'since': '',
'uptime': '9w4d'},
{'downtime': '',
'name': 'L3 Link VR',
'port': 'Te6/0/1.602',
'since': '',
'uptime': '9w4d'}

ACTUAL RESULTS
textfsm.parser.TextFSMError: State Error raised. Rule Line: 32. Input Line: Twe6/0/1.602   L3 Link VR 00:00:00       9w4d
@kuraijay
Copy link

would maybe using the below work better?

Value PORT (\S+)

@mjbear
Copy link
Contributor

mjbear commented Feb 23, 2024

would maybe using the below work better?

Value PORT (\S+)

@kuraijay , @brianatlarge

\S+ would probably work out better in the long run

It is simpler than adding (\.[0-9]+)? to the end of that already long and complex regex. 😬
The below works, but I don't see a reason why \S+ couldn't be used instead.
Value PORT ([a-zA-Z]{2,3}[0-9]{1,2}\/[0-9]{1,2}(\/[0-9]{1,2})?(\.[0-9]+)?)

@mjbear
Copy link
Contributor

mjbear commented Feb 23, 2024

The line formatting looks a little odd. I'd expect the "columns" to generally line up.
Example:
Twe5/0/1.602 L3 Link VR 00:00:00 9w4d

The sample output from above with the header line

Port           Name               Down Time      Up Time
Te5/0/1                           43w5d
Te5/0/2                           43w5d
Te5/0/3                           43w5d
Te5/0/4                           43w5d
Te5/0/5                           43w5d
Te5/0/6                           43w5d
Te5/0/7                           43w5d
Te5/0/8                           43w5d
Fo5/0/9                           43w5d
Fo5/0/10                          43w5d
Twe5/0/1       L3 Link            00:00:00       9w4d
Twe5/0/1.602   L3 Link VR 00:00:00       9w4d
Twe5/0/1.603   L3 Link VRF    00:00:00       9w4d
Twe5/0/5                          43w5d
Ap5/0/1                           43w5d
Te6/0/1                           43w5d
Te6/0/2                           43w5d
Te6/0/3                           43w5d
Te6/0/4                           43w5d
Te6/0/5                           43w5d
Te6/0/6                           43w5d
Te6/0/7                           43w5d
Te6/0/8                           43w5d
Fo6/0/9                           43w5d
Fo6/0/10                          43w5d
Twe6/0/1       L3 Link            00:00:00       9w4d
Twe6/0/1.602   L3 Link VR 00:00:00       9w4d
Twe6/0/1.603   L3 Link VRF    00:00:00       9w4d
Twe6/0/5                          43w5d

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

No branches or pull requests

3 participants