From c1d31983b263af1cb7e49ba27a6755b79d2163cc Mon Sep 17 00:00:00 2001 From: Cuong Nguyen Date: Sun, 16 Oct 2022 14:17:59 +0800 Subject: [PATCH] Fix Cisco NXOS `display inventory` Reordering the order of Regex such that the more specific will be used before the more generic ones --- .../cisco_nxos_show_inventory.textfsm | 3 +- .../cisco_nxos_show_inventory2.raw | 179 +++++++++++ .../cisco_nxos_show_inventory2.yml | 302 ++++++++++++++++++ 3 files changed, 482 insertions(+), 2 deletions(-) create mode 100644 tests/cisco_nxos/show_inventory/cisco_nxos_show_inventory2.raw create mode 100644 tests/cisco_nxos/show_inventory/cisco_nxos_show_inventory2.yml diff --git a/ntc_templates/templates/cisco_nxos_show_inventory.textfsm b/ntc_templates/templates/cisco_nxos_show_inventory.textfsm index e36f449f44..75198fe2f0 100644 --- a/ntc_templates/templates/cisco_nxos_show_inventory.textfsm +++ b/ntc_templates/templates/cisco_nxos_show_inventory.textfsm @@ -8,11 +8,10 @@ Start ^NAME:\s+"${NAME}",\s+DESCR:\s+"${DESCR}" ^NAME:\s+${NAME},\s+DESCR:\s+${DESCR} ^PID:\s+${PID}.*,.*VID:\s+${VID}.*SN:\s+${SN} -> Record - ^PID:\s+,.*VID:\s+${VID}.*SN: -> Record ^PID:\s+${PID}.*,.*VID:\s+${VID}.*SN: -> Record ^PID:\s+,.*VID:\s+${VID}.*SN:\s+${SN} -> Record + ^PID:\s+,.*VID:\s+${VID}.*SN: -> Record ^PID:\s+${PID}.*,.*VID:\s+${VID}.* ^PID:\s+,.*VID:\s+${VID}.* ^.*SN:\s+${SN} -> Record ^.*SN: -> Record - diff --git a/tests/cisco_nxos/show_inventory/cisco_nxos_show_inventory2.raw b/tests/cisco_nxos/show_inventory/cisco_nxos_show_inventory2.raw new file mode 100644 index 0000000000..1b0e2e1b03 --- /dev/null +++ b/tests/cisco_nxos/show_inventory/cisco_nxos_show_inventory2.raw @@ -0,0 +1,179 @@ +NAME: "Chassis", DESCR: "Nexus9000 93180YC-EX chassis" +PID: N9K-C93180YC-EX , VID: V03 , SN: FDO223607FK + +NAME: "Slot 1", DESCR: "48x10/25G + 6x40/100G Ethernet Module" +PID: N9K-C93180YC-EX , VID: V03 , SN: FDO223607FK + +NAME: "Power Supply 1", DESCR: "Nexus9000 93180YC-EX chassis Power Supply" +PID: NXA-PAC-650W-PE , VID: V02 , SN: ART2227FNDG + +NAME: "Power Supply 2", DESCR: "Nexus9000 93180YC-EX chassis Power Supply" +PID: NXA-PAC-650W-PE , VID: V02 , SN: ART2227FNDR + +NAME: "Fan 1", DESCR: "Nexus9000 93180YC-EX chassis Fan Module" +PID: NXA-FAN-30CFM-F , VID: V01 , SN: N/A + +NAME: "Fan 2", DESCR: "Nexus9000 93180YC-EX chassis Fan Module" +PID: NXA-FAN-30CFM-F , VID: V01 , SN: N/A + +NAME: "Fan 3", DESCR: "Nexus9000 93180YC-EX chassis Fan Module" +PID: NXA-FAN-30CFM-F , VID: V01 , SN: N/A + +NAME: "Fan 4", DESCR: "Nexus9000 93180YC-EX chassis Fan Module" +PID: NXA-FAN-30CFM-F , VID: V01 , SN: N/A + +NAME: Ethernet1/1, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804088868 + +NAME: Ethernet1/2, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804088875 + +NAME: Ethernet1/3, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804088869 + +NAME: Ethernet1/4, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804088877 + +NAME: Ethernet1/5, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804088866 + +NAME: Ethernet1/6, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804088876 + +NAME: Ethernet1/7, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804088867 + +NAME: Ethernet1/8, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804088870 + +NAME: Ethernet1/9, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804088865 + +NAME: Ethernet1/10, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804088872 + +NAME: Ethernet1/11, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804088863 + +NAME: Ethernet1/12, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804088871 + +NAME: Ethernet1/13, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804088864 + +NAME: Ethernet1/14, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804088874 + +NAME: Ethernet1/15, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804088861 + +NAME: Ethernet1/16, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804088873 + +NAME: Ethernet1/17, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804088862 + +NAME: Ethernet1/18, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804088879 + +NAME: Ethernet1/19, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804088860 + +NAME: Ethernet1/20, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804088878 + +NAME: Ethernet1/21, DESCR: FS +PID: , VID: SFP-10GSR-85, SN: F1811032996 + +NAME: Ethernet1/22, DESCR: FS +PID: , VID: SFP-10GSR-85, SN: F1811033037 + +NAME: Ethernet1/23, DESCR: FS +PID: , VID: SFP-10GSR-85, SN: F1811028643 + +NAME: Ethernet1/24, DESCR: FS +PID: , VID: SFP-10GSR-85, SN: F1811026706 + +NAME: Ethernet1/25, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804109689 + +NAME: Ethernet1/26, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804098192 + +NAME: Ethernet1/27, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804109688 + +NAME: Ethernet1/28, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804098190 + +NAME: Ethernet1/29, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804109685 + +NAME: Ethernet1/30, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804098218 + +NAME: Ethernet1/31, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804109687 + +NAME: Ethernet1/32, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804098193 + +NAME: Ethernet1/33, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804109684 + +NAME: Ethernet1/34, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804098194 + +NAME: Ethernet1/35, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804109686 + +NAME: Ethernet1/36, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804098195 + +NAME: Ethernet1/37, DESCR: FS +PID: , VID: SFP-10GSR-85, SN: C2004051466 + +NAME: Ethernet1/38, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804098196 + +NAME: Ethernet1/39, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804109683 + +NAME: Ethernet1/40, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804103664 + +NAME: Ethernet1/41, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804109681 + +NAME: Ethernet1/42, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804098198 + +NAME: Ethernet1/43, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804098197 + +NAME: Ethernet1/44, DESCR: FiberStore +PID: , VID: SFP-10GSR-85, SN: G1804098199 + +NAME: Ethernet1/45, DESCR: FS +PID: , VID: SFP-10GSR-85, SN: F1811032804 + +NAME: Ethernet1/46, DESCR: FS +PID: , VID: SFP-10GSR-85, SN: F1811032154 + +NAME: Ethernet1/47, DESCR: FS +PID: , VID: SFP-10GSR-85, SN: F1809025918 + +NAME: Ethernet1/48, DESCR: FS +PID: , VID: SFP-10GSR-85, SN: F1811026574 + +NAME: Ethernet1/49, DESCR: CISCO-FOIT +PID: QSFP-40/100-SRBD , VID: SFBR-89BDDZ-CS2, SN: FOF2229N3NH + +NAME: Ethernet1/50, DESCR: CISCO-FOIT +PID: QSFP-40/100-SRBD , VID: SFBR-89BDDZ-CS2, SN: FOF2229N3NJ + +NAME: Ethernet1/53, DESCR: CISCO-AVAGO +PID: QSFP-40G-SR-BD , VID: AFBR-79EBPZ-CS2, SN: AVM2210U0RA + +NAME: Ethernet1/54, DESCR: CISCO-AVAGO +PID: QSFP-40G-SR-BD , VID: AFBR-79EBPZ-CS2, SN: AVM2211U2VW diff --git a/tests/cisco_nxos/show_inventory/cisco_nxos_show_inventory2.yml b/tests/cisco_nxos/show_inventory/cisco_nxos_show_inventory2.yml new file mode 100644 index 0000000000..191a82fc1e --- /dev/null +++ b/tests/cisco_nxos/show_inventory/cisco_nxos_show_inventory2.yml @@ -0,0 +1,302 @@ +--- +parsed_sample: + - name: "Chassis" + descr: "Nexus9000 93180YC-EX chassis" + pid: "N9K-C93180YC-EX" + vid: "V03" + sn: "FDO223607FK" + - name: "Slot 1" + descr: "48x10/25G + 6x40/100G Ethernet Module" + pid: "N9K-C93180YC-EX" + vid: "V03" + sn: "FDO223607FK" + - name: "Power Supply 1" + descr: "Nexus9000 93180YC-EX chassis Power Supply" + pid: "NXA-PAC-650W-PE" + vid: "V02" + sn: "ART2227FNDG" + - name: "Power Supply 2" + descr: "Nexus9000 93180YC-EX chassis Power Supply" + pid: "NXA-PAC-650W-PE" + vid: "V02" + sn: "ART2227FNDR" + - name: "Fan 1" + descr: "Nexus9000 93180YC-EX chassis Fan Module" + pid: "NXA-FAN-30CFM-F" + vid: "V01" + sn: "N/A" + - name: "Fan 2" + descr: "Nexus9000 93180YC-EX chassis Fan Module" + pid: "NXA-FAN-30CFM-F" + vid: "V01" + sn: "N/A" + - name: "Fan 3" + descr: "Nexus9000 93180YC-EX chassis Fan Module" + pid: "NXA-FAN-30CFM-F" + vid: "V01" + sn: "N/A" + - name: "Fan 4" + descr: "Nexus9000 93180YC-EX chassis Fan Module" + pid: "NXA-FAN-30CFM-F" + vid: "V01" + sn: "N/A" + - name: "Ethernet1/1" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804088868" + - name: "Ethernet1/2" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804088875" + - name: "Ethernet1/3" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804088869" + - name: "Ethernet1/4" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804088877" + - name: "Ethernet1/5" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804088866" + - name: "Ethernet1/6" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804088876" + - name: "Ethernet1/7" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804088867" + - name: "Ethernet1/8" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804088870" + - name: "Ethernet1/9" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804088865" + - name: "Ethernet1/10" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804088872" + - name: "Ethernet1/11" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804088863" + - name: "Ethernet1/12" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804088871" + - name: "Ethernet1/13" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804088864" + - name: "Ethernet1/14" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804088874" + - name: "Ethernet1/15" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804088861" + - name: "Ethernet1/16" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804088873" + - name: "Ethernet1/17" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804088862" + - name: "Ethernet1/18" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804088879" + - name: "Ethernet1/19" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804088860" + - name: "Ethernet1/20" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804088878" + - name: "Ethernet1/21" + descr: "FS" + pid: "" + vid: "SFP-10GSR-85" + sn: "F1811032996" + - name: "Ethernet1/22" + descr: "FS" + pid: "" + vid: "SFP-10GSR-85" + sn: "F1811033037" + - name: "Ethernet1/23" + descr: "FS" + pid: "" + vid: "SFP-10GSR-85" + sn: "F1811028643" + - name: "Ethernet1/24" + descr: "FS" + pid: "" + vid: "SFP-10GSR-85" + sn: "F1811026706" + - name: "Ethernet1/25" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804109689" + - name: "Ethernet1/26" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804098192" + - name: "Ethernet1/27" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804109688" + - name: "Ethernet1/28" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804098190" + - name: "Ethernet1/29" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804109685" + - name: "Ethernet1/30" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804098218" + - name: "Ethernet1/31" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804109687" + - name: "Ethernet1/32" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804098193" + - name: "Ethernet1/33" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804109684" + - name: "Ethernet1/34" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804098194" + - name: "Ethernet1/35" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804109686" + - name: "Ethernet1/36" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804098195" + - name: "Ethernet1/37" + descr: "FS" + pid: "" + vid: "SFP-10GSR-85" + sn: "C2004051466" + - name: "Ethernet1/38" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804098196" + - name: "Ethernet1/39" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804109683" + - name: "Ethernet1/40" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804103664" + - name: "Ethernet1/41" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804109681" + - name: "Ethernet1/42" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804098198" + - name: "Ethernet1/43" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804098197" + - name: "Ethernet1/44" + descr: "FiberStore" + pid: "" + vid: "SFP-10GSR-85" + sn: "G1804098199" + - name: "Ethernet1/45" + descr: "FS" + pid: "" + vid: "SFP-10GSR-85" + sn: "F1811032804" + - name: "Ethernet1/46" + descr: "FS" + pid: "" + vid: "SFP-10GSR-85" + sn: "F1811032154" + - name: "Ethernet1/47" + descr: "FS" + pid: "" + vid: "SFP-10GSR-85" + sn: "F1809025918" + - name: "Ethernet1/48" + descr: "FS" + pid: "" + vid: "SFP-10GSR-85" + sn: "F1811026574" + - name: "Ethernet1/49" + descr: "CISCO-FOIT" + pid: "QSFP-40/100-SRBD" + vid: "SFBR-89BDDZ-CS2" + sn: "FOF2229N3NH" + - name: "Ethernet1/50" + descr: "CISCO-FOIT" + pid: "QSFP-40/100-SRBD" + vid: "SFBR-89BDDZ-CS2" + sn: "FOF2229N3NJ" + - name: "Ethernet1/53" + descr: "CISCO-AVAGO" + pid: "QSFP-40G-SR-BD" + vid: "AFBR-79EBPZ-CS2" + sn: "AVM2210U0RA" + - name: "Ethernet1/54" + descr: "CISCO-AVAGO" + pid: "QSFP-40G-SR-BD" + vid: "AFBR-79EBPZ-CS2" + sn: "AVM2211U2VW"