From 29b815693c4609df4659281e2dd8a50521f25fa5 Mon Sep 17 00:00:00 2001 From: caribouHY Date: Tue, 14 Jan 2025 15:12:50 +0000 Subject: [PATCH 1/4] add template for Fsas Si-R show ip route --- .../templates/fsas_sir_show_ip_route.textfsm | 15 ++ ntc_templates/templates/index | 1 + .../show_ip_route/fsas_sir_show_ip_route.raw | 26 +++ .../show_ip_route/fsas_sir_show_ip_route.yml | 194 ++++++++++++++++++ 4 files changed, 236 insertions(+) create mode 100644 ntc_templates/templates/fsas_sir_show_ip_route.textfsm create mode 100644 tests/fsas_sir/show_ip_route/fsas_sir_show_ip_route.raw create mode 100644 tests/fsas_sir/show_ip_route/fsas_sir_show_ip_route.yml diff --git a/ntc_templates/templates/fsas_sir_show_ip_route.textfsm b/ntc_templates/templates/fsas_sir_show_ip_route.textfsm new file mode 100644 index 0000000000..d48984d5fb --- /dev/null +++ b/ntc_templates/templates/fsas_sir_show_ip_route.textfsm @@ -0,0 +1,15 @@ +Value FLAG ([\*X]) +Value PROTOCOL (\w+) +Value NETWORK (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) +Value PREFIX_LENGTH (\d{1,2}) +Value GATEWAY (\S+) +Value DISTANCE (\d+) +Value UPTIME (\S+) +Value INTERFACE (\w+) + +Start + ^FP\s+Destination\/Mask + ^[-\s]+$$ + ^(\s|${FLAG})${PROTOCOL}\s+${NETWORK}\/${PREFIX_LENGTH}\s+${GATEWAY}\s+${DISTANCE}\s+${UPTIME}\s+${INTERFACE}\s*$$ -> Record + ^\s*$$ + ^. -> Error diff --git a/ntc_templates/templates/index b/ntc_templates/templates/index index 6727c36647..403af1b7fe 100644 --- a/ntc_templates/templates/index +++ b/ntc_templates/templates/index @@ -635,6 +635,7 @@ fortinet_execute_time.textfsm, .*, fortinet, exec[[ute]] ti[[me]] fsas_sir_show_system_information.textfsm, .*, fsas_sir, sh[[ow]] sys[[tem]] i[[nformation]] fsas_sir_show_ether.textfsm, .*, fsas_sir, sh[[ow]] eth[[er]] +fsas_sir_show_ip_route.textfsm, .*, fsas_sir, sh[[ow]] ip ro[[ute]] hp_comware_display_lldp_neighbor-information_verbose.textfsm, .*, hp_comware, di[[splay]] ll[[dp]] n[[eighbor-information]] v[[erbose]] hp_comware_display_lldp_neighbor-information_list.textfsm, .*, hp_comware, di[[splay]] ll[[dp]] n[[eighbor-information]] l[[ist]] diff --git a/tests/fsas_sir/show_ip_route/fsas_sir_show_ip_route.raw b/tests/fsas_sir/show_ip_route/fsas_sir_show_ip_route.raw new file mode 100644 index 0000000000..a1fcb68617 --- /dev/null +++ b/tests/fsas_sir/show_ip_route/fsas_sir_show_ip_route.raw @@ -0,0 +1,26 @@ +FP Destination/Mask Gateway Distance UpTime Interface +--- ------------------ --------------- -------- --------- ------------------ +*S 0.0.0.0/0 192.168.50.1 1 04:56:03 lan1 +*O 1.1.1.1/32 192.168.50.231 110 01:58:56 lan1 +*A 2.2.2.2/32 192.168.50.231 110 01:58:56 lan1 +*O 4.4.4.4/32 192.168.50.234 110 01:26:24 lan1 +*Bi 5.5.5.5/32 192.168.50.235 200 00:48:30 lan1 + E2 10.1.12.0/24 192.168.50.231 110 00:00:00 lan1 +*S 10.1.12.0/24 192.168.50.231 1 04:06:01 lan1 +*E2 10.1.13.0/29 192.168.50.231 110 6d23h45m lan1 +*E1 10.2.100.0/24 192.168.50.231 110 01:58:55 lan1 +*O 10.3.3.0/28 172.21.120.2 110 01:59:06 rmt1 +*C 10.3.120.1/32 10.3.120.1 0 04:36:48 lo0 + R 10.4.1.0/24 192.168.50.234 120 00:00:00 lan1 +*O 10.4.1.0/24 192.168.50.231 110 01:26:24 lan1 +*R 10.4.99.0/24 192.168.50.234 120 01:06:38 lan1 +*Be 10.6.13.0/24 192.168.50.236 20 00:16:09 lan1 +*Be 10.6.99.0/24 192.168.50.236 20 00:31:14 lan1 +*S 10.120.9.9/32 rmt2 1 3w6d23h rmt2 +*C 10.255.255.0/24 10.255.255.1 0 01:01:38 lan7 +*A 172.16.1.0/28 192.168.50.231 110 01:58:56 lan1 +*O 172.21.1.0/31 172.21.120.2 110 01:17:14 rmt1 +XO 172.21.120.0/30 172.21.120.2 110 01:59:06 rmt1 +*L 172.21.120.1/32 172.21.120.1 0 03:54:11 rmt1 +*C 172.21.120.2/32 172.21.120.1 0 03:54:11 rmt1 +*C 192.168.50.0/24 192.168.50.21 0 04:56:03 lan1 diff --git a/tests/fsas_sir/show_ip_route/fsas_sir_show_ip_route.yml b/tests/fsas_sir/show_ip_route/fsas_sir_show_ip_route.yml new file mode 100644 index 0000000000..bceda6f0bf --- /dev/null +++ b/tests/fsas_sir/show_ip_route/fsas_sir_show_ip_route.yml @@ -0,0 +1,194 @@ +--- +parsed_sample: + - distance: "1" + flag: "*" + gateway: "192.168.50.1" + interface: "lan1" + network: "0.0.0.0" + prefix_length: "0" + protocol: "S" + uptime: "04:56:03" + - distance: "110" + flag: "*" + gateway: "192.168.50.231" + interface: "lan1" + network: "1.1.1.1" + prefix_length: "32" + protocol: "O" + uptime: "01:58:56" + - distance: "110" + flag: "*" + gateway: "192.168.50.231" + interface: "lan1" + network: "2.2.2.2" + prefix_length: "32" + protocol: "A" + uptime: "01:58:56" + - distance: "110" + flag: "*" + gateway: "192.168.50.234" + interface: "lan1" + network: "4.4.4.4" + prefix_length: "32" + protocol: "O" + uptime: "01:26:24" + - distance: "200" + flag: "*" + gateway: "192.168.50.235" + interface: "lan1" + network: "5.5.5.5" + prefix_length: "32" + protocol: "Bi" + uptime: "00:48:30" + - distance: "110" + flag: "" + gateway: "192.168.50.231" + interface: "lan1" + network: "10.1.12.0" + prefix_length: "24" + protocol: "E2" + uptime: "00:00:00" + - distance: "1" + flag: "*" + gateway: "192.168.50.231" + interface: "lan1" + network: "10.1.12.0" + prefix_length: "24" + protocol: "S" + uptime: "04:06:01" + - distance: "110" + flag: "*" + gateway: "192.168.50.231" + interface: "lan1" + network: "10.1.13.0" + prefix_length: "29" + protocol: "E2" + uptime: "6d23h45m" + - distance: "110" + flag: "*" + gateway: "192.168.50.231" + interface: "lan1" + network: "10.2.100.0" + prefix_length: "24" + protocol: "E1" + uptime: "01:58:55" + - distance: "110" + flag: "*" + gateway: "172.21.120.2" + interface: "rmt1" + network: "10.3.3.0" + prefix_length: "28" + protocol: "O" + uptime: "01:59:06" + - distance: "0" + flag: "*" + gateway: "10.3.120.1" + interface: "lo0" + network: "10.3.120.1" + prefix_length: "32" + protocol: "C" + uptime: "04:36:48" + - distance: "120" + flag: "" + gateway: "192.168.50.234" + interface: "lan1" + network: "10.4.1.0" + prefix_length: "24" + protocol: "R" + uptime: "00:00:00" + - distance: "110" + flag: "*" + gateway: "192.168.50.231" + interface: "lan1" + network: "10.4.1.0" + prefix_length: "24" + protocol: "O" + uptime: "01:26:24" + - distance: "120" + flag: "*" + gateway: "192.168.50.234" + interface: "lan1" + network: "10.4.99.0" + prefix_length: "24" + protocol: "R" + uptime: "01:06:38" + - distance: "20" + flag: "*" + gateway: "192.168.50.236" + interface: "lan1" + network: "10.6.13.0" + prefix_length: "24" + protocol: "Be" + uptime: "00:16:09" + - distance: "20" + flag: "*" + gateway: "192.168.50.236" + interface: "lan1" + network: "10.6.99.0" + prefix_length: "24" + protocol: "Be" + uptime: "00:31:14" + - distance: "1" + flag: "*" + gateway: "rmt2" + interface: "rmt2" + network: "10.120.9.9" + prefix_length: "32" + protocol: "S" + uptime: "3w6d23h" + - distance: "0" + flag: "*" + gateway: "10.255.255.1" + interface: "lan7" + network: "10.255.255.0" + prefix_length: "24" + protocol: "C" + uptime: "01:01:38" + - distance: "110" + flag: "*" + gateway: "192.168.50.231" + interface: "lan1" + network: "172.16.1.0" + prefix_length: "28" + protocol: "A" + uptime: "01:58:56" + - distance: "110" + flag: "*" + gateway: "172.21.120.2" + interface: "rmt1" + network: "172.21.1.0" + prefix_length: "31" + protocol: "O" + uptime: "01:17:14" + - distance: "110" + flag: "X" + gateway: "172.21.120.2" + interface: "rmt1" + network: "172.21.120.0" + prefix_length: "30" + protocol: "O" + uptime: "01:59:06" + - distance: "0" + flag: "*" + gateway: "172.21.120.1" + interface: "rmt1" + network: "172.21.120.1" + prefix_length: "32" + protocol: "L" + uptime: "03:54:11" + - distance: "0" + flag: "*" + gateway: "172.21.120.1" + interface: "rmt1" + network: "172.21.120.2" + prefix_length: "32" + protocol: "C" + uptime: "03:54:11" + - distance: "0" + flag: "*" + gateway: "192.168.50.21" + interface: "lan1" + network: "192.168.50.0" + prefix_length: "24" + protocol: "C" + uptime: "04:56:03" From 650e4a870539a7a72544d5f76d019dd7ca0b74db Mon Sep 17 00:00:00 2001 From: caribouHY Date: Tue, 14 Jan 2025 15:25:37 +0000 Subject: [PATCH 2/4] fix index order --- ntc_templates/templates/index | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ntc_templates/templates/index b/ntc_templates/templates/index index 403af1b7fe..bd5c9a6e6d 100644 --- a/ntc_templates/templates/index +++ b/ntc_templates/templates/index @@ -634,8 +634,8 @@ fortinet_execute_ping.textfsm, .*, fortinet, exec[[ute]] ping fortinet_execute_time.textfsm, .*, fortinet, exec[[ute]] ti[[me]] fsas_sir_show_system_information.textfsm, .*, fsas_sir, sh[[ow]] sys[[tem]] i[[nformation]] -fsas_sir_show_ether.textfsm, .*, fsas_sir, sh[[ow]] eth[[er]] fsas_sir_show_ip_route.textfsm, .*, fsas_sir, sh[[ow]] ip ro[[ute]] +fsas_sir_show_ether.textfsm, .*, fsas_sir, sh[[ow]] eth[[er]] hp_comware_display_lldp_neighbor-information_verbose.textfsm, .*, hp_comware, di[[splay]] ll[[dp]] n[[eighbor-information]] v[[erbose]] hp_comware_display_lldp_neighbor-information_list.textfsm, .*, hp_comware, di[[splay]] ll[[dp]] n[[eighbor-information]] l[[ist]] From 4e332102f13b091340e1cf68421239d5ab384cde Mon Sep 17 00:00:00 2001 From: caribouHY <59246671+caribouHY@users.noreply.github.com> Date: Wed, 15 Jan 2025 00:43:41 +0900 Subject: [PATCH 3/4] fix simpler regex Co-authored-by: Michael Bear <38406045+mjbear@users.noreply.github.com> --- ntc_templates/templates/fsas_sir_show_ip_route.textfsm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ntc_templates/templates/fsas_sir_show_ip_route.textfsm b/ntc_templates/templates/fsas_sir_show_ip_route.textfsm index d48984d5fb..425fb21413 100644 --- a/ntc_templates/templates/fsas_sir_show_ip_route.textfsm +++ b/ntc_templates/templates/fsas_sir_show_ip_route.textfsm @@ -1,7 +1,7 @@ -Value FLAG ([\*X]) +Value FLAG (\S) Value PROTOCOL (\w+) -Value NETWORK (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) -Value PREFIX_LENGTH (\d{1,2}) +Value NETWORK (\S+) +Value PREFIX_LENGTH (\d+) Value GATEWAY (\S+) Value DISTANCE (\d+) Value UPTIME (\S+) @@ -9,7 +9,7 @@ Value INTERFACE (\w+) Start ^FP\s+Destination\/Mask - ^[-\s]+$$ - ^(\s|${FLAG})${PROTOCOL}\s+${NETWORK}\/${PREFIX_LENGTH}\s+${GATEWAY}\s+${DISTANCE}\s+${UPTIME}\s+${INTERFACE}\s*$$ -> Record + ^---\s+ + ^\s*${FLAG}?${PROTOCOL}\s+${NETWORK}\/${PREFIX_LENGTH}\s+${GATEWAY}\s+${DISTANCE}\s+${UPTIME}\s+${INTERFACE}\s*$$ -> Record ^\s*$$ ^. -> Error From 8dc8f437915ec2a3e3f797821a1a88c9504e705e Mon Sep 17 00:00:00 2001 From: caribouHY <59246671+caribouHY@users.noreply.github.com> Date: Wed, 15 Jan 2025 01:03:07 +0900 Subject: [PATCH 4/4] fix regex of FLAG Co-authored-by: Michael Bear <38406045+mjbear@users.noreply.github.com> --- ntc_templates/templates/fsas_sir_show_ip_route.textfsm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ntc_templates/templates/fsas_sir_show_ip_route.textfsm b/ntc_templates/templates/fsas_sir_show_ip_route.textfsm index 425fb21413..0e05360e5c 100644 --- a/ntc_templates/templates/fsas_sir_show_ip_route.textfsm +++ b/ntc_templates/templates/fsas_sir_show_ip_route.textfsm @@ -10,6 +10,6 @@ Value INTERFACE (\w+) Start ^FP\s+Destination\/Mask ^---\s+ - ^\s*${FLAG}?${PROTOCOL}\s+${NETWORK}\/${PREFIX_LENGTH}\s+${GATEWAY}\s+${DISTANCE}\s+${UPTIME}\s+${INTERFACE}\s*$$ -> Record + ^(\s+|${FLAG})${PROTOCOL}\s+${NETWORK}\/${PREFIX_LENGTH}\s+${GATEWAY}\s+${DISTANCE}\s+${UPTIME}\s+${INTERFACE}\s*$$ -> Record ^\s*$$ ^. -> Error