networktocode/ntc-templates

cisco_ios_show_version.textfsm fails to match version on special builds

Closed this issue · 4 comments

ISSUE TYPE
  • Bug Report
TEMPLATE USING

cisco_ios_show_version.textfsm

Value VERSION (.+?)
Value ROMMON (\S+)
Value HOSTNAME (\S+)
Value UPTIME (.+)
Value RELOAD_REASON (.+?)
Value RUNNING_IMAGE (\S+)
Value List HARDWARE (\S+|\S+\d\S+)
Value List SERIAL (\S+)
Value CONFIG_REGISTER (\S+)
Value List MAC ([0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5})

Start
  ^.*Software\s.+\),\sVersion\s${VERSION},*\s+RELEASE.*
  ^ROM:\s+${ROMMON}
  ^\s*${HOSTNAME}\s+uptime\s+is\s+${UPTIME}
  ^[sS]ystem\s+image\s+file\s+is\s+"(.*?):${RUNNING_IMAGE}"
  ^(?:[lL]ast\s+reload\s+reason:|System\s+returned\s+to\s+ROM\s+by)\s+${RELOAD_REASON}\s*$$
  ^[Pp]rocessor\s+board\s+ID\s+${SERIAL}
  ^[Cc]isco\s+${HARDWARE}\s+\(.+\).+
  ^[Cc]onfiguration\s+register\s+is\s+${CONFIG_REGISTER}
  ^Base\s+[Ee]thernet\s+MAC\s+[Aa]ddress\s+:\s+${MAC}
  ^Switch\s+Port -> Stack
  # Capture time-stamp if vty line has command time-stamping turned on
  ^Load\s+for\s+
  ^Time\s+source\s+is


Stack
  ^[Ss]ystem\s+[Ss]erial\s+[Nn]umber\s+:\s+${SERIAL}
  ^[Mm]odel\s+[Nn]umber\s+:\s+${HARDWARE}\s*
  ^[Cc]onfiguration\s+register\s+is\s+${CONFIG_REGISTER}
  ^Base [Ee]thernet MAC [Aa]ddress\s+:\s+${MAC}
SAMPLE COMMAND OUTPUT

Engineering build

router#sh ver
Cisco IOS XE Software, Version V169_5_SR689355441_2
Cisco IOS Software [Fuji], ISR Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.9.5, CUST-SPECIAL:V169_5_SR689355441_2
This software is supported for a limited time under special agreement with Cisco Systems, Inc. SR689355441_2
Copyright (c) 1986-2020 by Cisco Systems, Inc.
Compiled Thu 17-Sep-20 16:00 by mcpre

Standard build

CORP-HANGAR-4431-1#sh ver
Cisco IOS XE Software, Version 16.09.05
Cisco IOS Software [Fuji], ISR Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.9.5, RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2020 by Cisco Systems, Inc.
Compiled Thu 30-Jan-20 18:53 by mcpre
SUMMARY

Cisco engineering builds do not include the usual "RELEASE SOFTWARE" as part of the show version output and instead include "CUST-SPECIAL". This prevents the regex from matching on the version.

STEPS TO REPRODUCE

run show version on engineering build. Sample output above.

EXPECTED RESULTS

Example would ideally match "Cisco IOS Software [Fuji], ISR Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.9.5," with an adjustment to the regex.

ACTUAL RESULTS

No version pulled

Can you give this a try?

^.*Software\s.+\),\sVersion\s${VERSION},*\s+(RELEASE|CUST-SPECIAL).*

I tested that against regular release builds and the engineering special builds I have access to and it works.

@dmiller3079
Has the Cisco custom build output changed any from your example above?

This one was a bit of a pain since normal releases have parentheses (ex: (fc1)) whereas the custom one does not. During testing once I made the parentheses optional for ${RELEASE} the matches get wonky. It works out best to have two lines, one for the regular releases and one for custom builds.

^.*Software,*\s+\(${SOFTWARE_IMAGE}\),\sVersion\s${VERSION},*\s+RELEASE.*\(${RELEASE}\)
^.*Software,*\s+\(${SOFTWARE_IMAGE}\),\sVersion\s${VERSION},*\s+\S+.*:${RELEASE}

Thoughts before I send in a PR?

submitted PR #1781