From d47c4f284de6437bd1a14f74a70908b10f69e8b0 Mon Sep 17 00:00:00 2001 From: Zachery Lantz Date: Thu, 9 Jan 2025 01:22:41 -0500 Subject: [PATCH 1/5] added new template for cisco fxos show firmware --- ntc_templates/templates/cisco_fxos_show_firmware.textfsm | 7 +++++++ ntc_templates/templates/index | 2 ++ .../cisco_fxos/show_firmware/cisco_fxos_show_firmware.raw | 2 ++ .../cisco_fxos/show_firmware/cisco_fxos_show_firmware.yml | 4 ++++ 4 files changed, 15 insertions(+) create mode 100644 ntc_templates/templates/cisco_fxos_show_firmware.textfsm create mode 100644 tests/cisco_fxos/show_firmware/cisco_fxos_show_firmware.raw create mode 100644 tests/cisco_fxos/show_firmware/cisco_fxos_show_firmware.yml diff --git a/ntc_templates/templates/cisco_fxos_show_firmware.textfsm b/ntc_templates/templates/cisco_fxos_show_firmware.textfsm new file mode 100644 index 0000000000..c2e806fb18 --- /dev/null +++ b/ntc_templates/templates/cisco_fxos_show_firmware.textfsm @@ -0,0 +1,7 @@ +Value VERSION (\S+) +Value STARTUP_VERSION (\S+) + +Start + ^\s*Version:\s+${VERSION}$$ + ^\s*Startup-Vers:\s+${STARTUP_VERSION}$$ + ^. -> Error \ No newline at end of file diff --git a/ntc_templates/templates/index b/ntc_templates/templates/index index 8b9b848698..3a14b62841 100644 --- a/ntc_templates/templates/index +++ b/ntc_templates/templates/index @@ -242,6 +242,8 @@ cisco_asa_dir.textfsm, .*, cisco_asa, dir cisco_ftd_show_vpn-sessiondb_anyconnect.textfsm, .*, cisco_ftd, sh[[ow]] vpn-[[sessiondb]] a[[nyconnect]] +cisco_fxos_show_firmware.textfsm, .*, cisco_fxos, sh[[ow]] fi[[rmware]] + cisco_ios_show_module.textfsm:cisco_ios_show_module_status.textfsm:cisco_ios_show_module_submodule.textfsm:cisco_ios_show_module_online_diag.textfsm, .*, cisco_ios, sh[[ow]] mod[[ule]] cisco_ios_show_switch_detail.textfsm:cisco_ios_show_switch_detail_stack_ports.textfsm, .*, cisco_ios, sh[[ow]] sw[[itch]] d[[etail]] cisco_ios_show_authentication_sessions_method_details.textfsm, .*, cisco_ios, show authen[[tication]] ses[[sions]] met[[hod]](\s+d[[ot1x]]|\s+m[[ab]])? det[[ails]] diff --git a/tests/cisco_fxos/show_firmware/cisco_fxos_show_firmware.raw b/tests/cisco_fxos/show_firmware/cisco_fxos_show_firmware.raw new file mode 100644 index 0000000000..02058a2fa8 --- /dev/null +++ b/tests/cisco_fxos/show_firmware/cisco_fxos_show_firmware.raw @@ -0,0 +1,2 @@ + Version: 2.16(0.128) + Startup-Vers: 2.16(0.128) \ No newline at end of file diff --git a/tests/cisco_fxos/show_firmware/cisco_fxos_show_firmware.yml b/tests/cisco_fxos/show_firmware/cisco_fxos_show_firmware.yml new file mode 100644 index 0000000000..144ecace35 --- /dev/null +++ b/tests/cisco_fxos/show_firmware/cisco_fxos_show_firmware.yml @@ -0,0 +1,4 @@ +--- +parsed_sample: + - startup_version: "2.16(0.128)" + version: "2.16(0.128)" From 1b5f7eec522b9a634ac969d9daaa13bccb68098c Mon Sep 17 00:00:00 2001 From: Zachery Lantz Date: Thu, 9 Jan 2025 09:01:01 -0500 Subject: [PATCH 2/5] updated fxos show firmware to not require changing to system scope prior to exec --- ...firmware.textfsm => cisco_fxos_show_system_firmware.textfsm} | 0 ntc_templates/templates/index | 2 +- .../cisco_fxos_show_system_firmware.raw} | 0 .../cisco_fxos_show_system_firmware.yml} | 0 4 files changed, 1 insertion(+), 1 deletion(-) rename ntc_templates/templates/{cisco_fxos_show_firmware.textfsm => cisco_fxos_show_system_firmware.textfsm} (100%) rename tests/cisco_fxos/{show_firmware/cisco_fxos_show_firmware.raw => show_system_firmware/cisco_fxos_show_system_firmware.raw} (100%) rename tests/cisco_fxos/{show_firmware/cisco_fxos_show_firmware.yml => show_system_firmware/cisco_fxos_show_system_firmware.yml} (100%) diff --git a/ntc_templates/templates/cisco_fxos_show_firmware.textfsm b/ntc_templates/templates/cisco_fxos_show_system_firmware.textfsm similarity index 100% rename from ntc_templates/templates/cisco_fxos_show_firmware.textfsm rename to ntc_templates/templates/cisco_fxos_show_system_firmware.textfsm diff --git a/ntc_templates/templates/index b/ntc_templates/templates/index index 3a14b62841..5d765b147a 100644 --- a/ntc_templates/templates/index +++ b/ntc_templates/templates/index @@ -242,7 +242,7 @@ cisco_asa_dir.textfsm, .*, cisco_asa, dir cisco_ftd_show_vpn-sessiondb_anyconnect.textfsm, .*, cisco_ftd, sh[[ow]] vpn-[[sessiondb]] a[[nyconnect]] -cisco_fxos_show_firmware.textfsm, .*, cisco_fxos, sh[[ow]] fi[[rmware]] +cisco_fxos_show_system_firmware.textfsm, .*, cisco_fxos, sh[[ow]] sy[[stem]] fi[[rmware]] cisco_ios_show_module.textfsm:cisco_ios_show_module_status.textfsm:cisco_ios_show_module_submodule.textfsm:cisco_ios_show_module_online_diag.textfsm, .*, cisco_ios, sh[[ow]] mod[[ule]] cisco_ios_show_switch_detail.textfsm:cisco_ios_show_switch_detail_stack_ports.textfsm, .*, cisco_ios, sh[[ow]] sw[[itch]] d[[etail]] diff --git a/tests/cisco_fxos/show_firmware/cisco_fxos_show_firmware.raw b/tests/cisco_fxos/show_system_firmware/cisco_fxos_show_system_firmware.raw similarity index 100% rename from tests/cisco_fxos/show_firmware/cisco_fxos_show_firmware.raw rename to tests/cisco_fxos/show_system_firmware/cisco_fxos_show_system_firmware.raw diff --git a/tests/cisco_fxos/show_firmware/cisco_fxos_show_firmware.yml b/tests/cisco_fxos/show_system_firmware/cisco_fxos_show_system_firmware.yml similarity index 100% rename from tests/cisco_fxos/show_firmware/cisco_fxos_show_firmware.yml rename to tests/cisco_fxos/show_system_firmware/cisco_fxos_show_system_firmware.yml From f1b8a462f916406653f44380ee1cae43aff2f2da Mon Sep 17 00:00:00 2001 From: Michael Bear <38406045+mjbear@users.noreply.github.com> Date: Thu, 9 Jan 2025 09:08:01 -0500 Subject: [PATCH 3/5] Augment and simplify regexes in alcatel_aos_sh_int_ethernet (#1966) --- ...catel_aos_show_interfaces_ethernet.textfsm | 80 +++++++++---------- ntc_templates/templates/index | 2 +- 2 files changed, 39 insertions(+), 43 deletions(-) diff --git a/ntc_templates/templates/alcatel_aos_show_interfaces_ethernet.textfsm b/ntc_templates/templates/alcatel_aos_show_interfaces_ethernet.textfsm index 088bf90598..06d70a3a47 100644 --- a/ntc_templates/templates/alcatel_aos_show_interfaces_ethernet.textfsm +++ b/ntc_templates/templates/alcatel_aos_show_interfaces_ethernet.textfsm @@ -1,21 +1,21 @@ Value PORT (\S+) Value STATUS (\S+) Value ADMIN_STATUS (\S+) -Value PORT_DOWN_VIOLATION_REASON (\S.+\S) -Value LAST_TIME_LINK_CHANGED (\S.+\S) +Value PORT_DOWN_VIOLATION_REASON (.+?) +Value LAST_TIME_LINK_CHANGED (.+?) Value NUMBER_OF_STATUS_CHANGE (\d+) -Value PORT_TYPE (\S.+\S) -Value SFP_XFP (\S.+\S) -Value INTERFACE_TYPE (\S.+\S) -Value ETHERNET_POWER_POLICY (\S.+\S) -Value LINK_QUALITY (\S.+\S) -Value MAC_ADDRESS (\S.+\S) +Value PORT_TYPE (.+?) +Value SFP_XFP (.+?) +Value INTERFACE_TYPE (.+?) +Value ETHERNET_POWER_POLICY (.+?) +Value LINK_QUALITY (.+?) +Value MAC_ADDRESS (.+?) Value BANDWIDTH (\d+) Value DUPLEX (\S+) -Value AUTONEGOTIATION (\S.+\S) +Value AUTONEGOTIATION (.+?) Value LONG_FRAME_SIZE (\d+) Value INTER_FRAME_GAP (\d+) -Value LOOPBACK_MODE (\S.+\S) +Value LOOPBACK_MODE (.+?) Value RX_BYTES_RECEIVED (\d+) Value RX_BROADCAST_FRAMES (\d+) Value RX_UNDERSIZE_FRAMES (\d+) @@ -39,48 +39,44 @@ Value TX_COLLISIONS (\d+) Value TX_LATE_COLLISIONS (\d+) Value TX_EXCESSIVE_COLLISIONS (\d+) - Start -# R6 - ^\s*Slot\/Port\s*${PORT}\s*:\s*$$ -# R8 - ^\s*Chassis\/Slot\/Port\s*:\s*${PORT}\s*$$ - ^\s*Operational\s*Status\s*:\s*${STATUS},\s*(?:"(?:${ADMIN_STATUS})?"\s*)?$$ - ^\s*Port-Down\/Violation\s*Reason\s*:\s*${PORT_DOWN_VIOLATION_REASON},\s*$$ - ^\s*Last\s*Time\s*Link\s*Changed\s*:\s*${LAST_TIME_LINK_CHANGED}\s*,\s*$$ - ^\s*Number\s*of\s*Status\s*Change\s*:\s*${NUMBER_OF_STATUS_CHANGE},\s*$$ - ^\s*Type\s*:\s*${PORT_TYPE},\s*$$ - ^\s*SFP\/(?:SFP\+\/)?XFP\s*:\s*${SFP_XFP},\s*$$ - ^\s*Interface\s*Type\s*:\s*${INTERFACE_TYPE},\s*$$ - ^\s*EPP\s*:\s*${ETHERNET_POWER_POLICY},\s*$$ - ^\s*Link-Quality\s*:\s*${LINK_QUALITY},\s*$$ - ^\s*MAC\s*address\s*:\s*${MAC_ADDRESS},\s*$$ - ^\s*BandWidth\s*\(Megabits\)\s*:\s*(-|${BANDWIDTH})\s*,\s*Duplex\s*:\s*(-|${DUPLEX})\s*,\s*$$ - ^\s*Autonegotiation\s*:\s*\d+\s*\[(\s*|\s*${AUTONEGOTIATION}\s*)\],\s*$$ - ^\s*Long\s*Frame\s*Size\(Bytes\)\s*:\s*${LONG_FRAME_SIZE},\s*$$ - ^\s*Inter\s*Frame\s*Gap\(Bytes\)\s*:\s*${INTER_FRAME_GAP},\s*$$ - ^\s*loopback\s*mode\s*:\s*${LOOPBACK_MODE},\s*$$ + ^\s*(Chassis\/)?Slot\/Port\s*(:\s+)?${PORT}(\s+:)?\s*$$ + ^\s*Operational\s+Status\s*:\s+${STATUS},(?:\s+"(?:${ADMIN_STATUS})?")?\s*$$ + ^\s*Port-Down\/Violation\s+Reason\s*:\s+${PORT_DOWN_VIOLATION_REASON},\s*$$ + ^\s*Last\s+Time\s+Link\s+Changed\s*:\s+${LAST_TIME_LINK_CHANGED}\s*,\s*$$ + ^\s*Number\s+of\s+Status\s+Change\s*:\s+${NUMBER_OF_STATUS_CHANGE},\s*$$ + ^\s*Type\s*:\s+${PORT_TYPE},\s*$$ + ^\s*(?:SFP\+?\/)+XFP\s*:\s+${SFP_XFP},\s*$$ + ^\s*Interface\s+Type\s*:\s+${INTERFACE_TYPE},\s*$$ + ^\s*EPP\s*:\s+${ETHERNET_POWER_POLICY},\s*$$ + ^\s*Link-Quality\s*:\s+${LINK_QUALITY},\s*$$ + ^\s*MAC\s+address\s*:\s+${MAC_ADDRESS},\s*$$ + ^\s*Band[Ww]idth\s+\(Megabits\)\s*:\s+(-|${BANDWIDTH})\s*,\s+Duplex\s+:\s+(-|${DUPLEX})\s*,\s*$$ + ^\s*Autonegotiation\s*:\s+\d+\s+\[(\s*${AUTONEGOTIATION}?\s*)\],\s*$$ + ^\s*Long\s+Frame\s+Size\(Bytes\)\s*:\s+${LONG_FRAME_SIZE},\s*$$ + ^\s*Inter\s+Frame\s+Gap\(Bytes\)\s*:\s+${INTER_FRAME_GAP},\s*$$ + ^\s*loopback\s+mode\s*:\s+${LOOPBACK_MODE},\s*$$ ^\s*Rx\s*:\s*$$ -> RX_Table ^\s*Tx\s*:\s*$$ -> TX_Table ^\s*$$ ^.+ -> Error RX_Table - ^\s*Bytes\s*Received\s*:\s*${RX_BYTES_RECEIVED},\s*Unicast\s*Frames\s*:\s*${RX_UNICAST_FRAMES},\s*$$ - ^\s*Broadcast\s*Frames\s*:\s*${RX_BROADCAST_FRAMES},\s*M-cast\s*Frames\s*:\s*${RX_MULTICAST_FRAMES},\s*$$ - ^\s*UnderSize\s*Frames\s*:\s*${RX_UNDERSIZE_FRAMES},\s*OverSize\s*Frames\s*:\s*${RX_OVERSIZE_FRAMES},\s*$$ - ^\s*Lost\s*Frames\s*:\s*${RX_LOST_FRAMES},\s*Error\s*Frames\s*:\s*${RX_ERROR_FRAMES},\s*$$ - ^\s*CRC\s*Error\s*Frames\s*:\s*${RX_CRC_ERROR_FRAMES},\s*Alignments\s*Err\s*:\s*${RX_ALIGNMENT_ERRORS},\s*$$ -> Start + ^\s*Bytes\s+Received\s*:\s+${RX_BYTES_RECEIVED},\s+Unicast\s+Frames\s*:\s+${RX_UNICAST_FRAMES},\s*$$ + ^\s*Broadcast\s+Frames\s*:\s+${RX_BROADCAST_FRAMES},\s+M-cast\s+Frames\s*:\s+${RX_MULTICAST_FRAMES},\s*$$ + ^\s*UnderSize\s+Frames\s*:\s+${RX_UNDERSIZE_FRAMES},\s+OverSize\s+Frames\s*:\s+${RX_OVERSIZE_FRAMES},\s*$$ + ^\s*Lost\s+Frames\s*:\s+${RX_LOST_FRAMES},\s+Error\s+Frames\s*:\s+${RX_ERROR_FRAMES},\s*$$ + ^\s*CRC\s+Error\s+Frames\s*:\s+${RX_CRC_ERROR_FRAMES},\s+Alignments\s+Err\s*:\s+${RX_ALIGNMENT_ERRORS},\s*$$ -> Start ^\s*$$ ^. -> Error TX_Table - ^\s*Bytes\s*Xmitted\s*:\s*${TX_BYTES_TRANSMITTED},\s*Unicast\s*Frames\s*:\s*${TX_UNICAST_FRAMES},\s*$$ - ^\s*Broadcast\s*Frames\s*:\s*${TX_BROADCAST_FRAMES},\s*M-cast\s*Frames\s*:\s*${TX_MULTICAST_FRAMES},\s*$$ - ^\s*UnderSize\s*Frames\s*:\s*${TX_UNDERSIZE_FRAMES},\s*OverSize\s*Frames\s*:\s*${TX_OVERSIZE_FRAMES},\s*$$ - ^\s*Lost\s*Frames\s*:\s*${TX_LOST_FRAMES},\s*Collided\s*Frames\s*:\s*${TX_COLLIDED_FRAMES},\s*$$ - ^\s*Error\s*Frames\s*:\s*${TX_ERROR_FRAMES}\s*$$ -> Record Start - ^\s*Error\s*Frames\s*:\s*${TX_ERROR_FRAMES}(?:,\s*Collisions\s*:\s*${TX_COLLISIONS},)?\s*$$ - ^\s*Late\s*collisions\s*:\s*${TX_LATE_COLLISIONS},\s*Exc-Collisions\s*:\s*${TX_EXCESSIVE_COLLISIONS}\s*$$ -> Record Start + ^\s*Bytes\s+Xmitted\s*:\s+${TX_BYTES_TRANSMITTED},\s+Unicast\s+Frames\s*:\s+${TX_UNICAST_FRAMES},\s*$$ + ^\s*Broadcast\s+Frames\s*:\s+${TX_BROADCAST_FRAMES},\s+M-cast\s+Frames\s*:\s+${TX_MULTICAST_FRAMES},\s*$$ + ^\s*UnderSize\s+Frames\s*:\s+${TX_UNDERSIZE_FRAMES},\s+OverSize\s+Frames\s*:\s+${TX_OVERSIZE_FRAMES},\s*$$ + ^\s*Lost\s+Frames\s*:\s+${TX_LOST_FRAMES},\s+Collided\s+Frames\s*:\s+${TX_COLLIDED_FRAMES},\s*$$ + ^\s*Error\s+Frames\s*:\s+${TX_ERROR_FRAMES}\s*$$ -> Record Start + ^\s*Error\s+Frames\s*:\s+${TX_ERROR_FRAMES}(?:,\s+Collisions\s*:\s+${TX_COLLISIONS},)?\s*$$ + ^\s*Late\s+collisions\s*:\s+${TX_LATE_COLLISIONS},\s+Exc-Collisions\s*:\s+${TX_EXCESSIVE_COLLISIONS}\s*$$ -> Record Start ^\s*$$ ^. -> Error diff --git a/ntc_templates/templates/index b/ntc_templates/templates/index index 5d765b147a..b2e60f5023 100644 --- a/ntc_templates/templates/index +++ b/ntc_templates/templates/index @@ -11,7 +11,7 @@ # Template, Hostname, Platform, Command -alcatel_aos_show_interfaces_ethernet.textfsm, .*, alcatel_aos, sh[[ow]] (in[[terfaces]] e[[thernet]]|in[[terfaces]])$$ +alcatel_aos_show_interfaces_ethernet.textfsm, .*, alcatel_aos, sh[[ow]] (in[[terfaces]] e[[thernet]]|in[[terfaces]])$ alcatel_aos_show_lldp_remote-system.textfsm, .*, alcatel_aos, sh[[ow]] lldp r[[emote-system]] alcatel_aos_show_interfaces_status.textfsm, .*, alcatel_aos, sh[[ow]] in[[terfaces]] st[[atus]] alcatel_aos_show_mac-address-table.textfsm, .*, alcatel_aos, sh[[ow]] mac-(a[[ddress-table]]|l[[earning]]) From 589a6d111edf8c5eadaa5287d9473d332b22eadd Mon Sep 17 00:00:00 2001 From: Michael Bear <38406045+mjbear@users.noreply.github.com> Date: Thu, 9 Jan 2025 20:13:54 -0500 Subject: [PATCH 4/5] Add cisco_fxos to OS choices list --- tests/test_index_order.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_index_order.py b/tests/test_index_order.py index 0d329b1e9b..2b4aa72f71 100755 --- a/tests/test_index_order.py +++ b/tests/test_index_order.py @@ -26,6 +26,7 @@ "cisco_apic", "cisco_asa", "cisco_ftd", + "cisco_fxos", "cisco_ios", "cisco_nvfis", "cisco_nxos", From a153400bb9c4e273b522a9820de5c5c58d5167db Mon Sep 17 00:00:00 2001 From: Jacob McGill <9847006+jmcgill298@users.noreply.github.com> Date: Mon, 13 Jan 2025 13:50:13 -0500 Subject: [PATCH 5/5] Apply suggestions from code review --- .../templates/cisco_fxos_show_system_firmware.textfsm | 6 +++--- .../cisco_fxos_show_system_firmware.raw | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ntc_templates/templates/cisco_fxos_show_system_firmware.textfsm b/ntc_templates/templates/cisco_fxos_show_system_firmware.textfsm index c2e806fb18..dfa3c5b407 100644 --- a/ntc_templates/templates/cisco_fxos_show_system_firmware.textfsm +++ b/ntc_templates/templates/cisco_fxos_show_system_firmware.textfsm @@ -2,6 +2,6 @@ Value VERSION (\S+) Value STARTUP_VERSION (\S+) Start - ^\s*Version:\s+${VERSION}$$ - ^\s*Startup-Vers:\s+${STARTUP_VERSION}$$ - ^. -> Error \ No newline at end of file + ^\s*Version:\s+${VERSION}\s*$$ + ^\s*Startup-Vers:\s+${STARTUP_VERSION}\s*$$ + ^. -> Error diff --git a/tests/cisco_fxos/show_system_firmware/cisco_fxos_show_system_firmware.raw b/tests/cisco_fxos/show_system_firmware/cisco_fxos_show_system_firmware.raw index 02058a2fa8..33e9cec429 100644 --- a/tests/cisco_fxos/show_system_firmware/cisco_fxos_show_system_firmware.raw +++ b/tests/cisco_fxos/show_system_firmware/cisco_fxos_show_system_firmware.raw @@ -1,2 +1,2 @@ Version: 2.16(0.128) - Startup-Vers: 2.16(0.128) \ No newline at end of file + Startup-Vers: 2.16(0.128)