Skip to content

Fix truncated SN and PID in cisco_ios show inventory - #2377

Merged
matt852 merged 3 commits into
networktocode:masterfrom
MahakSangwan:fix-cisco-ios-show-inventory-sn-pid
Nov 18, 2026
Merged

matt852 merged 3 commits into
networktocode:masterfrom
MahakSangwan:fix-cisco-ios-show-inventory-sn-pid

Conversation

@MahakSangwan

Copy link
Copy Markdown
Contributor
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT

cisco_ios_show_inventory (cisco_ios, show inventory)

SUMMARY

Two values were cut short:

  • SN was captured with ([\w+\d+]+), which stops at the first character outside letters, digits, _ and +. Serials of Cisco AOC/DAC and breakout cables carry a suffix such as -A, -B or -CH1, so SN: APF22340C1D-B parsed as APF22340C1D. On a QSFP-to-4xSFP breakout cable, all four legs (...-CH1 to ...-CH4) parsed to the same serial.
  • PID was cut at the first space: PID: Samsung SSD 860 EVO 250GB , VID: ... parsed as Samsung (seen on an ASR/ISR disk).

Changes:

-Value PID (([\S+]+|.*))
+Value PID ((?:[^,]*[^,\s])?)
-Value SN ([\w+\d+]+)
+Value SN (\S+)

PID now takes everything up to the last non-space character before the comma. It is still optional, so a blank PID (PID: , VID: 0xFF, SN: FF1045C5 in cisco_ios_show_inventory.raw) keeps its SN. The rules are unchanged.

The new test cisco_ios_show_inventory_sn_dash_pid_space covers dashed AOC/DAC serials, the four legs of a breakout cable and a PID with spaces, in the IOS XE layout (padded values, trailing spaces after SN). Serials are made up. The existing show_inventory tests pass unchanged, and so does the full test suite locally.

🤖 Generated with Claude Code

SN was captured with ([\w+\d+]+), which stops at the first character
outside letters, digits, "_" and "+". Serials of Cisco AOC/DAC and
breakout cables carry a suffix such as "-A", "-B" or "-CH1", so
"APF22340C1D-B" parsed as "APF22340C1D", and the four legs of a
breakout cable all got the same serial. SN is now (\S+).

PID was cut at the first space ("Samsung SSD 860 EVO 250GB" parsed as
"Samsung"). PID now takes everything up to the last non-space before
the comma, and may still be empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

MahakSangwan added a commit to MahakSangwan/NetworkSDK that referenced this pull request Nov 11, 2026
get_inventory() sends only `show inventory`. Neither engine is right as
released: Genie crashes or drops items, ntc-templates 9.3 cuts serials at
the first "-" and part IDs at a space. We ship a corrected copy of the
ntc-templates template (two Value lines changed, sent upstream as
networktocode/ntc-templates#2377) and parse_textfsm() gains a template
argument. A test fails once the released template is fixed, so the copy
gets deleted. Fixtures: 30 genieparser and 2 ntc-templates samples.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@matt852
matt852 merged commit aa53c94 into networktocode:master Nov 18, 2026
14 checks passed
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 this pull request may close these issues.

3 participants