Add hp_comware_display_version - #2337
Conversation
matt852
left a comment
There was a problem hiding this comment.
Recommendation: Changes Required
Breaking Change: No
Thanks @Ardeck — this is a lot of ground covered (Comware v5 standalone, v7 standalone, and multi-chassis all in one template), and the three fixtures are genuinely good coverage. Two things to address before merge:
-
The two
Compiledrules collide, sosystem_compile_dateis never populated.^\s+Compiled\s+${BOOT_COMPILE_DATE}and^\s+Compiled\s+${SYSTEM_COMPILE_DATE}are byte-identical, and TextFSM stops at the first match — so the boot rule consumes both lines.boot_compile_dateends up holding the system image's date andsystem_compile_datestays empty. Fixture 2 hides it because both images share a timestamp, but on a device where they differ the output is wrong. Splitting the two blocks into their own states fixes it.In
hp_comware_display_version.textfsm, theStartstate:^Last reboot reason\s*:\s*${LAST_REBOOT_REASON} - ^Boot image:\s+${BOOT_IMAGE} - ^Boot image version:\s+${BOOT_IMAGE_VERSION},\s+Release\s+${BOOT_RELEASE} - ^\s+Compiled\s+${BOOT_COMPILE_DATE} - ^System image:\s+${SYSTEM_IMAGE} - ^System image version:\s+${SYSTEM_IMAGE_VERSION},\s+Release\s+${SYSTEM_RELEASE} - ^\s+Compiled\s+${SYSTEM_COMPILE_DATE} + ^Boot image:\s+${BOOT_IMAGE} -> BootImage + ^System image:\s+${SYSTEM_IMAGE} -> SystemImage # Standalone switch rules (e.g. HP 5800)And two new states, inserted just above
SlotSection:+BootImage + ^Boot image version:\s+${BOOT_IMAGE_VERSION},\s+Release\s+${BOOT_RELEASE} + ^\s+Compiled\s+${BOOT_COMPILE_DATE} -> Start + ^System image:\s+${SYSTEM_IMAGE} -> SystemImage + +SystemImage + ^System image version:\s+${SYSTEM_IMAGE_VERSION},\s+Release\s+${SYSTEM_RELEASE} + ^\s+Compiled\s+${SYSTEM_COMPILE_DATE} -> Start + SlotSection
And the fixture it corrects, in
tests/hp_comware/display_version/hp_comware_display_version2.yml:- system_compile_date: "" + system_compile_date: "Oct 12 2023 11:00:00"
-
Literal single spaces in the match patterns should be
\s+. Comware pads these columns differently across releases, soBOARD TYPE:/Uptime is/Boot image:etc. are brittle as written. This one doesn't change any parsed output — no fixture regeneration needed.In the
Startstate:- ^.*Comware Software,\s+Version\s+${SOFTWARE_VERSION},\s+Release\s+${RELEASE} - ^${MODEL}\s+uptime is\s+${UPTIME} - ^Last reboot reason\s*:\s*${LAST_REBOOT_REASON} - ^Boot image:\s+${BOOT_IMAGE} - ^Boot image version:\s+${BOOT_IMAGE_VERSION},\s+Release\s+${BOOT_RELEASE} + ^.*Comware\s+Software,\s+Version\s+${SOFTWARE_VERSION},\s+Release\s+${RELEASE} + ^${MODEL}\s+uptime\s+is\s+${UPTIME} + ^Last\s+reboot\s+reason\s*:\s*${LAST_REBOOT_REASON} + ^Boot\s+image:\s+${BOOT_IMAGE} + ^Boot\s+image\s+version:\s+${BOOT_IMAGE_VERSION},\s+Release\s+${BOOT_RELEASE}
- ^System image:\s+${SYSTEM_IMAGE} - ^System image version:\s+${SYSTEM_IMAGE_VERSION},\s+Release\s+${SYSTEM_RELEASE} + ^System\s+image:\s+${SYSTEM_IMAGE} + ^System\s+image\s+version:\s+${SYSTEM_IMAGE_VERSION},\s+Release\s+${SYSTEM_RELEASE}
- ^BootRom Version is ${BOOTROM_VERSION} + ^BootRom\s+Version\s+is\s+${BOOTROM_VERSION}
And in the
SlotSectionstate:- ^Uptime is ${SLOT_UPTIME} - ^BOARD TYPE:\s+${BOARD_TYPE} + ^Uptime\s+is\s+${SLOT_UPTIME} + ^BOARD\s+TYPE:\s+${BOARD_TYPE}
- ^(?:Bootrom|Bootware) Version:\s+${BOOTROM_VERSION} - ^BootRom Version is ${BOOTROM_VERSION} - ^Patch Version\s*:\s*${PATCH_VERSION} - ^Reboot Cause\s*:\s*${REBOOT_CAUSE} + ^(?:Bootrom|Bootware)\s+Version:\s+${BOOTROM_VERSION} + ^BootRom\s+Version\s+is\s+${BOOTROM_VERSION} + ^Patch\s+Version\s*:\s*${PATCH_VERSION} + ^Reboot\s+Cause\s*:\s*${REBOOT_CAUSE}
A few more worth picking up in the same pass:
-
The
PreStartstate never runs. TextFSM always begins inStart, so neitherPreStartrule can fire — theHP Comware Platform Softwarebanner is just falling through unmatched inStarttoday. Deleting the state produces identical output.-PreStart - ^HPE?\s+(?:HP\s+)?Comware\s+(?:Platform\s+)?Software,\s+Version\s+${SOFTWARE_VERSION},\s+Release\s+${RELEASE} -> Start - ^HPE?\s+(?:HP\s+)?Comware\s+Platform\s+Software -> Start - Start
-
SOFTWARE_VERSION→VERSIONfor cross-vendor consistency. Eleven of the 22 existingshow version/display versiontemplates use bareVERSIONfor the primary software version and none useSOFTWARE_VERSION.cisco_ios_show_versionis the exact parallel — it pairsVERSIONwithRELEASE, same as here.-Value Filldown SOFTWARE_VERSION (\S+) +Value Filldown VERSION (\S+)
Apply the same rename to the rule that references it, and to every
software_version:line in all three fixture files (invoke gen-yaml-folderwill regenerate them for you). -
Some useful fields in the raw output aren't captured yet.
Release Version:,PCB N Version:/Hardware Version is,CPLD N Version:, the processor type and count (with 1 BCM1125H Processor— dropped entirely insideSlotSection), the[SubSlot N]module lines, andConfig Register points to .... Worth grabbing now since adding capture groups later is a breaking change. I left this without a diff because how to decompose these (per-indexListvalues vs. flat) is your call. -
No state ends with
^. -> Error. Both nearest siblings (huawei_vrp_display_version,hp_procurve_show_version) have one, and it's what would have surfaced the dropped fields above. This needs to land together with the capture work — adding it as-is would fail all three fixtures — so pair it with explicit ignore rules for the lines you decide not to capture (^Copyright,^Config Register,^\[SubSlot,^\s*$$).
Thanks!
(review generated with Claude)
- capture each compiled date - remove prestart and include in start - Clean up space in pattern and replace them with \space - SOFTWARE_VERSION → VERSION - state ends with ^. -> Error - Multiple new fields captured to avoid errors - Use of lists for all variable under slots - various fix to accomodate variable format (:|is), optionnal space, various naming (BootRom,Bootrom,Bootware...) - add more samples to cover more type of hardware or version of software ... ....
|
I tried to fix everything but this is dying hardware mostly, but that are still running. The most difficult part is the moving format accross platform and version. The last commit handlings errors is also checked on a few hundreds of device and should catch most of the fields possible. |
This PR adds a new TextFSM parser for
display versionon HP / HPE Comware platforms (Comware v5 and v7).Supported Hardware & Topologies
MPU/LPUboards, properly extracting individual slot uptime, hardware types, and memory breakdown across chassis/slots.Slot X:headers.Parsing Highlights
UPTIMEandSLOT_UPTIMEstrings without truncation.StartSlotSection) to handle slot flushing cleanly viaContinue.Record, preventing missing or overwritten slot records (e.g., Slot 0).SOFTWARE_VERSION,RELEASE,MODEL,BOOT_IMAGE,SYSTEM_IMAGE, etc.) alongside hardware slot attributes (DRAM,NOR_FLASH,NAND_FLASH,BOARD_TYPE,BOOTROM_VERSION).Motivation
HP Comware devices lacked a standardized
display versionparser inntc-templates. Adding this template enables structured parsing of hardware inventory, software release details, and device/slot uptimes for network automation workflows using Nornir, Ansible, or Netmiko.Testing
.rawoutput samples added undertests/hp_comware/display_version/(covering both chassis and standalone switches)..ymlfiles generated viainvoke gen-yaml-folder.invoke pytest) — 100% passing.invoke yamllint).ntc_templates/templates/index.Checklist
ntc_templates/templates/ntc_templates/templates/index.rawand.yml) added intests/hp_comware/display_version/