networktocode/ntc-templates

Juniper "show chassis hardware" does not work for DAC cables

Closed this issue · 3 comments

ISSUE TYPE
  • Template Issue with error and raw data
  • Bug Report with the library
  • Feature - This is only relevant to the library, not templates
  • Documentation Report
TEMPLATE USING
https://github.com/networktocode/ntc-templates/blob/eaf22661cd9696f746884ffe2927f71f82f39370/ntc_templates/templates/juniper_junos_show_chassis_hardware.textfsm#L86C3-L86C117

SAMPLE COMMAND OUTPUT
Hardware inventory:
Item             Version  Part number  Serial number     Description
Chassis                                XH3123121334      Virtual Chassis
Routing Engine 0          BUILTIN      BUILTIN           RE-EX4650-48Y-8C
Routing Engine 1          BUILTIN      BUILTIN           RE-EX4650-48Y-8C
FPC 0            REV 17   650-023442   XH3723123134      JNP48Y8C-CHAS
  CPU                     BUILTIN      BUILTIN           FPC CPU
  PIC 0                   BUILTIN      BUILTIN           48x25G-8x100G
    Xcvr 4       REV 02   740-038291   F20124124477       SFP-T
    Xcvr 5       REV 02   740-038291   F20301231232       SFP-T
    Xcvr 6       REV 02   740-038291   F20312312342       SFP-T
    Xcvr 7       REV 02   740-038291   F20312142144       SFP-T
    Xcvr 54               740-061000   F2031241241-2     QSFP28-100G-CU1M
    Xcvr 55               740-061000   F2012312312-2     QSFP28-100G-CU1M
  Power Supply 0 REV 04   740-070749   1F18D012312       JPSU-650W-AC-AO
  Power Supply 1 REV 04   740-070749   1F18D123123       JPSU-650W-AC-AO
  Fan Tray 0                                             fan-ctrl-0 0, Front to Back Airflow - AFO
  Fan Tray 1                                             fan-ctrl-0 1, Front to Back Airflow - AFO
  Fan Tray 2                                             fan-ctrl-1 2, Front to Back Airflow - AFO
  Fan Tray 3                                             fan-ctrl-1 3, Front to Back Airflow - AFO
  Fan Tray 4                                             fan-ctrl-2 4, Front to Back Airflow - AFO
SUMMARY

DAC cables doesn't provide the "XCVR Version" (REV), can we make it optional?

STEPS TO REPRODUCE
EXPECTED RESULTS
ACTUAL RESULTS

Yes, by making a line that just accounts for empty space.

In addition to the revision needing to be empty, the serial number needs to allow for hypen.

Make the transceiver version and trailing whitespace optional
^\s*Xcvr\s+${XCVR_NUMBER}\s+(?:${XCVR_VERSION}\s+)?${XCVR_PART}\s+${XCVR_SERIAL_NUMBER}\s+${XCVR_DESCRIPTION} -> Record

Could add optional hypen and word ... but this is getting awful \w+ wordy 😆
XCVR_SERIAL_NUMBER = (\w+(-\w+)?)

Alternatively it is probably simpler to use \S+ for several capture groups (as listed below).

  • XCVR_PART
  • XCVR_SERIAL_NUMBER

I have a working solution for the moment, but haven't submitted a PR yet.
There are more groups that could be simplified and I'm considering doing that too.

Worked up PR #1721

I also have PR #1722 (branched off the above PR) for simplifying a few wordy regexes (pun intended).