From 790aa839260bff20e48d47c3f4e388d498edc81a Mon Sep 17 00:00:00 2001 From: pskliarenko <“pskliarenko@bsh.ru”> Date: Sun, 10 Sep 2023 22:32:03 +0400 Subject: [PATCH] Template + test --- .../fortinet_execute_traceroute.textfsm | 14 ++++++ ntc_templates/templates/index | 1 + .../fortinet_execute_traceroute1.raw | 3 ++ .../fortinet_execute_traceroute1.yml | 17 +++++++ .../fortinet_execute_traceroute2.raw | 7 +++ .../fortinet_execute_traceroute2.yml | 44 +++++++++++++++++++ 6 files changed, 86 insertions(+) create mode 100644 ntc_templates/templates/fortinet_execute_traceroute.textfsm create mode 100644 tests/fortinet/execute_traceroute/fortinet_execute_traceroute1.raw create mode 100644 tests/fortinet/execute_traceroute/fortinet_execute_traceroute1.yml create mode 100644 tests/fortinet/execute_traceroute/fortinet_execute_traceroute2.raw create mode 100644 tests/fortinet/execute_traceroute/fortinet_execute_traceroute2.yml diff --git a/ntc_templates/templates/fortinet_execute_traceroute.textfsm b/ntc_templates/templates/fortinet_execute_traceroute.textfsm new file mode 100644 index 0000000000..3c99170bf9 --- /dev/null +++ b/ntc_templates/templates/fortinet_execute_traceroute.textfsm @@ -0,0 +1,14 @@ +Value DESTINATION_ADDRESS (\S+) +Value HOPS_MAX (\d+) +Value PACKETS_PER_HOP (\d+) +Value PACKET_SIZE (\d+) +Value HOP_NUM (\d+) +Value ADDRESS ((?!\*(?:\s+\*)*)\S+) +Value DETAILS (.*) + +Start + ^\s*traceroute\s+to\s+${DESTINATION_ADDRESS}\s+\(.*?\),\s+${HOPS_MAX}\s+hops\s+max,\s+${PACKETS_PER_HOP}\s+probe\s+packets\s+per\s+hop,\s+${PACKET_SIZE}\s+byte\s+packets\s*$$ + ^\s*${HOP_NUM}(?:\s+${ADDRESS})?\s+${DETAILS}\s*$$ -> Record + ^\s*\*\s*$$ + ^\s*$$ + ^. -> Error diff --git a/ntc_templates/templates/index b/ntc_templates/templates/index index 3a5b516184..a87aa70fb0 100644 --- a/ntc_templates/templates/index +++ b/ntc_templates/templates/index @@ -485,6 +485,7 @@ fortinet_get_system_interface_physical.textfsm, .*, fortinet, g[[et]] sy[[stem]] fortinet_get_router_info_bgp_summary.textfsm, .*, fortinet, g[[et]] r[[outer]] info bg[[p]] su[[mmary]] fortinet_get_system_ha_status.textfsm, .*, fortinet, g[[et]] sy[[stem]] ha s[[tatus]] fortinet_get_system_interface.textfsm, .*, fortinet, g[[et]] sy[[stem]] in[[terface]] +fortinet_execute_traceroute.textfsm, .*, fortinet, exec[[ute]] traceroute fortinet_get_system_status.textfsm, .*, fortinet, g[[et]] sy[[stem]] stat[[us]] fortinet_get_system_arp.textfsm, .*, fortinet, g[[et]] sy[[stem]] arp diff --git a/tests/fortinet/execute_traceroute/fortinet_execute_traceroute1.raw b/tests/fortinet/execute_traceroute/fortinet_execute_traceroute1.raw new file mode 100644 index 0000000000..26e9edaa97 --- /dev/null +++ b/tests/fortinet/execute_traceroute/fortinet_execute_traceroute1.raw @@ -0,0 +1,3 @@ +traceroute to 8.8.8.8 (8.8.8.8), 32 hops max, 10 probe packets per hop, 84 byte packets + 1 1.2.3.4 0.454 ms 0.503 ms 0.262 ms 0.191 ms 0.187 ms 0.191 ms 0.191 ms 0.192 ms 0.193 ms 0.185 ms + 2 5.6.7.8 1.225 ms * * * diff --git a/tests/fortinet/execute_traceroute/fortinet_execute_traceroute1.yml b/tests/fortinet/execute_traceroute/fortinet_execute_traceroute1.yml new file mode 100644 index 0000000000..d3307ef79c --- /dev/null +++ b/tests/fortinet/execute_traceroute/fortinet_execute_traceroute1.yml @@ -0,0 +1,17 @@ +--- +parsed_sample: + - address: "1.2.3.4" + destination_address: "8.8.8.8" + details: "0.454 ms 0.503 ms 0.262 ms 0.191 ms 0.187 ms 0.191 ms 0.191 ms\ + \ 0.192 ms 0.193 ms 0.185 ms" + hop_num: "1" + hops_max: "32" + packet_size: "84" + packets_per_hop: "10" + - address: "5.6.7.8" + destination_address: "" + details: "1.225 ms * * *" + hop_num: "2" + hops_max: "" + packet_size: "" + packets_per_hop: "" diff --git a/tests/fortinet/execute_traceroute/fortinet_execute_traceroute2.raw b/tests/fortinet/execute_traceroute/fortinet_execute_traceroute2.raw new file mode 100644 index 0000000000..3324c50465 --- /dev/null +++ b/tests/fortinet/execute_traceroute/fortinet_execute_traceroute2.raw @@ -0,0 +1,7 @@ +traceroute to 8.8.8.8 (8.8.8.8), 32 hops max, 3 probe packets per hop, 84 byte packets + 1 1.2.3.4 0.423 ms 2.123 ms 0.274 ms + 2 5.6.7.8 0.389 ms 0.445 ms 0.178 ms + 3 * * * + 4 * * * + 5 * * * + 6 8.8.8.8 15.494 ms 15.488 ms 15.469 ms diff --git a/tests/fortinet/execute_traceroute/fortinet_execute_traceroute2.yml b/tests/fortinet/execute_traceroute/fortinet_execute_traceroute2.yml new file mode 100644 index 0000000000..5142ee4180 --- /dev/null +++ b/tests/fortinet/execute_traceroute/fortinet_execute_traceroute2.yml @@ -0,0 +1,44 @@ +--- +parsed_sample: + - address: "1.2.3.4" + destination_address: "8.8.8.8" + details: "0.423 ms 2.123 ms 0.274 ms" + hop_num: "1" + hops_max: "32" + packet_size: "84" + packets_per_hop: "3" + - address: "5.6.7.8" + destination_address: "" + details: "0.389 ms 0.445 ms 0.178 ms" + hop_num: "2" + hops_max: "" + packet_size: "" + packets_per_hop: "" + - address: "" + destination_address: "" + details: "* * *" + hop_num: "3" + hops_max: "" + packet_size: "" + packets_per_hop: "" + - address: "" + destination_address: "" + details: "* * *" + hop_num: "4" + hops_max: "" + packet_size: "" + packets_per_hop: "" + - address: "" + destination_address: "" + details: "* * *" + hop_num: "5" + hops_max: "" + packet_size: "" + packets_per_hop: "" + - address: "8.8.8.8" + destination_address: "" + details: "15.494 ms 15.488 ms 15.469 ms" + hop_num: "6" + hops_max: "" + packet_size: "" + packets_per_hop: ""