From 995b75ea605091196d82ddbed3ad2fc5d959c017 Mon Sep 17 00:00:00 2001 From: pskliarenko <“pskliarenko@bsh.ru”> Date: Sun, 10 Sep 2023 23:08:32 +0400 Subject: [PATCH 1/2] Template + test --- ntc_templates/templates/index | 1 + ...p_route_print_terse_without-paging.textfsm | 24 +++++ ...os_ip_route_print_terse_without-paging.raw | 5 + ...os_ip_route_print_terse_without-paging.yml | 97 +++++++++++++++++++ 4 files changed, 127 insertions(+) create mode 100644 ntc_templates/templates/mikrotik_routeros_ip_route_print_terse_without-paging.textfsm create mode 100644 tests/mikrotik_routeros/ip_route_print_terse_without-paging/mikrotik_routeros_ip_route_print_terse_without-paging.raw create mode 100644 tests/mikrotik_routeros/ip_route_print_terse_without-paging/mikrotik_routeros_ip_route_print_terse_without-paging.yml diff --git a/ntc_templates/templates/index b/ntc_templates/templates/index index 3a5b516184..31c78df53d 100644 --- a/ntc_templates/templates/index +++ b/ntc_templates/templates/index @@ -570,6 +570,7 @@ mikrotik_routeros_ip_dhcp-server_lease_print_without-paging.textfsm, .*, mikroti mikrotik_routeros_ip_firewall_nat_print_all_without-paging.textfsm, .*, mikrotik_routeros, [[/]]ip(v6)? firewall nat print all without-paging mikrotik_routeros_interface_ethernet_monitor_name_once.textfsm, .*, mikrotik_routeros, [[/]]interface ethernet monitor (\S+) once mikrotik_routeros_ip_firewall_address-list_print_terse.textfsm, .*, mikrotik_routeros, [[/]]ip(v6)? firewall address-list print terse +mikrotik_routeros_ip_route_print_terse_without-paging.textfsm, .*, mikrotik_routeros, [[/]]ip r[[oute]] p[[rint]] t[[erse]] wi[[thout-paging]] mikrotik_routeros_snmp_community_print_without-paging.textfsm, .*, mikrotik_routeros, [[/]]snmp community print without-paging mikrotik_routeros_ipv6_neighbor_print_without-paging.textfsm, .*, mikrotik_routeros, [[/]]ipv6 neighbor print without-paging mikrotik_routeros_ip_arp_print_without-paging.textfsm, .*, mikrotik_routeros, [[/]]ip arp print without-paging diff --git a/ntc_templates/templates/mikrotik_routeros_ip_route_print_terse_without-paging.textfsm b/ntc_templates/templates/mikrotik_routeros_ip_route_print_terse_without-paging.textfsm new file mode 100644 index 0000000000..024a30a3fb --- /dev/null +++ b/ntc_templates/templates/mikrotik_routeros_ip_route_print_terse_without-paging.textfsm @@ -0,0 +1,24 @@ +Value Key INDEX (\d+) +Value FLAGS ([XADCSrbomBUP ]{4}) +Value COMMENT (.*?(?=(?:[^=]\S+=)|\s*$)) +Value DST_ADDRESS (\S+) +Value DST_ADDRESS_SUBNET (\d+) +Value TYPE (.+?(?=(?:[^=]\S+=)|\s*$)) +Value ROUTING_TABLE (.+?(?=(?:[^=]\S+=)|\s*$)) +Value PREF_SRC (\S+?) +Value GATEWAY (.+?(?=(?:[^=]\S+=)|\s*$)) +Value GATEWAY_STATUS (.+?(?=(?:[^=]\S+=)|\s*$)) +Value IMMEDIATE_GW (.+?(?=(?:[^=]\S+=)|\s*$)) +Value CHECK_GATEWAY (.+?(?=(?:[^=]\S+=)|\s*$)) +Value DISTANCE (\d+) +Value SCOPE (\d+) +Value TARGET_SCOPE (\d+) +Value VRF_INTERFACE (.+?(?=(?:[^=]\S+=)|\s*$)) +Value SUPPRESS_HW_OFFLOAD (yes|no) +Value LOCAL_ADDRESS (.+?(?=(?:[^=]\S+=)|\s*$)) +Value ROUTING_MARK (.*?(?=(?:[^=]\S+=)|\s*$)) + +Start + ^\s*${INDEX}\s+${FLAGS}(?:\s+comment=${COMMENT})?\s+dst-address=${DST_ADDRESS}/${DST_ADDRESS_SUBNET}(?:\s+type=${TYPE})?(?:\s+routing-table=${ROUTING_TABLE})?(?:\s+pref-src=${PREF_SRC})?(?:\s+gateway=${GATEWAY})?(?:\s+gateway-status=${GATEWAY_STATUS})?(?:\s+immediate-gw=${IMMEDIATE_GW})?(?:\s+check-gateway=${CHECK_GATEWAY})?(?:\s+distance=${DISTANCE})?(?:\s+scope=${SCOPE})?(?:\s+target-scope=${TARGET_SCOPE})?(?:\s+vrf-interface=${VRF_INTERFACE})?(?:\s+suppress-hw-offload=${SUPPRESS_HW_OFFLOAD})?(?:\s+local-address=${LOCAL_ADDRESS})?(?:\s+routing-mark=${ROUTING_MARK})?\s*$$ -> Record + ^\s*$$ + ^. -> Error diff --git a/tests/mikrotik_routeros/ip_route_print_terse_without-paging/mikrotik_routeros_ip_route_print_terse_without-paging.raw b/tests/mikrotik_routeros/ip_route_print_terse_without-paging/mikrotik_routeros_ip_route_print_terse_without-paging.raw new file mode 100644 index 0000000000..ac32857fb3 --- /dev/null +++ b/tests/mikrotik_routeros/ip_route_print_terse_without-paging/mikrotik_routeros_ip_route_print_terse_without-paging.raw @@ -0,0 +1,5 @@ + 0 A S dst-address=0.0.0.0/0 gateway=192.168.8.1 gateway-status=192.168.8.1 reachable via lte1 distance=2 scope=30 target-scope=10 vrf-interface=lte1 + 1 ADC dst-address=10.160.1.228/30 pref-src=10.160.1.230 gateway=ether1 gateway-status=ether1 reachable distance=0 scope=10 + 2 A S comment=to Internet dst-address=134.0.0.0/8 gateway=10.160.1.230 gateway-status=10.160.1.230 reachable via ether2 distance=1 scope=30 target-scope=10 routing-mark=reserve + 3 A S dst-address=172.0.0.0/8 gateway=1.2.3.4 gateway-status=1.2.3.4 recursive via 10.152.1.230 ether5 distance=1 scope=30 target-scope=10 routing-mark=Free_Wi-Fi + 4 A SB dst-address=10.0.0.0/8 type=blackhole distance=100 routing-mark=Free_Wi-Fi diff --git a/tests/mikrotik_routeros/ip_route_print_terse_without-paging/mikrotik_routeros_ip_route_print_terse_without-paging.yml b/tests/mikrotik_routeros/ip_route_print_terse_without-paging/mikrotik_routeros_ip_route_print_terse_without-paging.yml new file mode 100644 index 0000000000..7d0bac76a6 --- /dev/null +++ b/tests/mikrotik_routeros/ip_route_print_terse_without-paging/mikrotik_routeros_ip_route_print_terse_without-paging.yml @@ -0,0 +1,97 @@ +--- +parsed_sample: + - check_gateway: "" + comment: "" + distance: "2" + dst_address: "0.0.0.0" + dst_address_subnet: "0" + flags: "A S " + gateway: "192.168.8.1" + gateway_status: "192.168.8.1 reachable via lte1" + immediate_gw: "" + index: "0" + local_address: "" + pref_src: "" + routing_mark: "" + routing_table: "" + scope: "30" + suppress_hw_offload: "" + target_scope: "10" + type: "" + vrf_interface: "lte1" + - check_gateway: "" + comment: "" + distance: "0" + dst_address: "10.160.1.228" + dst_address_subnet: "30" + flags: "ADC " + gateway: "ether1" + gateway_status: "ether1 reachable" + immediate_gw: "" + index: "1" + local_address: "" + pref_src: "10.160.1.230" + routing_mark: "" + routing_table: "" + scope: "10" + suppress_hw_offload: "" + target_scope: "" + type: "" + vrf_interface: "" + - check_gateway: "" + comment: "to Internet" + distance: "1" + dst_address: "134.0.0.0" + dst_address_subnet: "8" + flags: "A S " + gateway: "10.160.1.230" + gateway_status: "10.160.1.230 reachable via ether2" + immediate_gw: "" + index: "2" + local_address: "" + pref_src: "" + routing_mark: "reserve" + routing_table: "" + scope: "30" + suppress_hw_offload: "" + target_scope: "10" + type: "" + vrf_interface: "" + - check_gateway: "" + comment: "" + distance: "1" + dst_address: "172.0.0.0" + dst_address_subnet: "8" + flags: "A S " + gateway: "1.2.3.4" + gateway_status: "1.2.3.4 recursive via 10.152.1.230 ether5" + immediate_gw: "" + index: "3" + local_address: "" + pref_src: "" + routing_mark: "Free_Wi-Fi" + routing_table: "" + scope: "30" + suppress_hw_offload: "" + target_scope: "10" + type: "" + vrf_interface: "" + - check_gateway: "" + comment: "" + distance: "100" + dst_address: "10.0.0.0" + dst_address_subnet: "8" + flags: "A SB" + gateway: "" + gateway_status: "" + immediate_gw: "" + index: "4" + local_address: "" + pref_src: "" + routing_mark: "Free_Wi-Fi" + routing_table: "" + scope: "" + suppress_hw_offload: "" + target_scope: "" + type: "blackhole" + vrf_interface: "" From 59f42d4955c8690712da254d499887c43c939385 Mon Sep 17 00:00:00 2001 From: Jacob McGill <9847006+jmcgill298@users.noreply.github.com> Date: Mon, 22 Jul 2024 17:26:59 -0400 Subject: [PATCH 2/2] Apply suggestions from code review --- ...p_route_print_terse_without-paging.textfsm | 8 ++++---- ...os_ip_route_print_terse_without-paging.yml | 20 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ntc_templates/templates/mikrotik_routeros_ip_route_print_terse_without-paging.textfsm b/ntc_templates/templates/mikrotik_routeros_ip_route_print_terse_without-paging.textfsm index 024a30a3fb..751a2043ce 100644 --- a/ntc_templates/templates/mikrotik_routeros_ip_route_print_terse_without-paging.textfsm +++ b/ntc_templates/templates/mikrotik_routeros_ip_route_print_terse_without-paging.textfsm @@ -1,8 +1,8 @@ -Value Key INDEX (\d+) +Value INDEX (\d+) Value FLAGS ([XADCSrbomBUP ]{4}) Value COMMENT (.*?(?=(?:[^=]\S+=)|\s*$)) -Value DST_ADDRESS (\S+) -Value DST_ADDRESS_SUBNET (\d+) +Value DESTINATION_ADDRESS (\S+) +Value DESTINATION_ADDRESS_SUBNET (\d+) Value TYPE (.+?(?=(?:[^=]\S+=)|\s*$)) Value ROUTING_TABLE (.+?(?=(?:[^=]\S+=)|\s*$)) Value PREF_SRC (\S+?) @@ -19,6 +19,6 @@ Value LOCAL_ADDRESS (.+?(?=(?:[^=]\S+=)|\s*$)) Value ROUTING_MARK (.*?(?=(?:[^=]\S+=)|\s*$)) Start - ^\s*${INDEX}\s+${FLAGS}(?:\s+comment=${COMMENT})?\s+dst-address=${DST_ADDRESS}/${DST_ADDRESS_SUBNET}(?:\s+type=${TYPE})?(?:\s+routing-table=${ROUTING_TABLE})?(?:\s+pref-src=${PREF_SRC})?(?:\s+gateway=${GATEWAY})?(?:\s+gateway-status=${GATEWAY_STATUS})?(?:\s+immediate-gw=${IMMEDIATE_GW})?(?:\s+check-gateway=${CHECK_GATEWAY})?(?:\s+distance=${DISTANCE})?(?:\s+scope=${SCOPE})?(?:\s+target-scope=${TARGET_SCOPE})?(?:\s+vrf-interface=${VRF_INTERFACE})?(?:\s+suppress-hw-offload=${SUPPRESS_HW_OFFLOAD})?(?:\s+local-address=${LOCAL_ADDRESS})?(?:\s+routing-mark=${ROUTING_MARK})?\s*$$ -> Record + ^\s*${INDEX}\s+${FLAGS}(?:\s+comment=${COMMENT})?\s+dst-address=${DESTINATION_ADDRESS}/${DESTINATION_ADDRESS_SUBNET}(?:\s+type=${TYPE})?(?:\s+routing-table=${ROUTING_TABLE})?(?:\s+pref-src=${PREF_SRC})?(?:\s+gateway=${GATEWAY})?(?:\s+gateway-status=${GATEWAY_STATUS})?(?:\s+immediate-gw=${IMMEDIATE_GW})?(?:\s+check-gateway=${CHECK_GATEWAY})?(?:\s+distance=${DISTANCE})?(?:\s+scope=${SCOPE})?(?:\s+target-scope=${TARGET_SCOPE})?(?:\s+vrf-interface=${VRF_INTERFACE})?(?:\s+suppress-hw-offload=${SUPPRESS_HW_OFFLOAD})?(?:\s+local-address=${LOCAL_ADDRESS})?(?:\s+routing-mark=${ROUTING_MARK})?\s*$$ -> Record ^\s*$$ ^. -> Error diff --git a/tests/mikrotik_routeros/ip_route_print_terse_without-paging/mikrotik_routeros_ip_route_print_terse_without-paging.yml b/tests/mikrotik_routeros/ip_route_print_terse_without-paging/mikrotik_routeros_ip_route_print_terse_without-paging.yml index 7d0bac76a6..b6b5e669a1 100644 --- a/tests/mikrotik_routeros/ip_route_print_terse_without-paging/mikrotik_routeros_ip_route_print_terse_without-paging.yml +++ b/tests/mikrotik_routeros/ip_route_print_terse_without-paging/mikrotik_routeros_ip_route_print_terse_without-paging.yml @@ -3,8 +3,8 @@ parsed_sample: - check_gateway: "" comment: "" distance: "2" - dst_address: "0.0.0.0" - dst_address_subnet: "0" + destination_address: "0.0.0.0" + destination_address_subnet: "0" flags: "A S " gateway: "192.168.8.1" gateway_status: "192.168.8.1 reachable via lte1" @@ -22,8 +22,8 @@ parsed_sample: - check_gateway: "" comment: "" distance: "0" - dst_address: "10.160.1.228" - dst_address_subnet: "30" + destination_address: "10.160.1.228" + destination_address_subnet: "30" flags: "ADC " gateway: "ether1" gateway_status: "ether1 reachable" @@ -41,8 +41,8 @@ parsed_sample: - check_gateway: "" comment: "to Internet" distance: "1" - dst_address: "134.0.0.0" - dst_address_subnet: "8" + destination_address: "134.0.0.0" + destination_address_subnet: "8" flags: "A S " gateway: "10.160.1.230" gateway_status: "10.160.1.230 reachable via ether2" @@ -60,8 +60,8 @@ parsed_sample: - check_gateway: "" comment: "" distance: "1" - dst_address: "172.0.0.0" - dst_address_subnet: "8" + destination_address: "172.0.0.0" + destination_address_subnet: "8" flags: "A S " gateway: "1.2.3.4" gateway_status: "1.2.3.4 recursive via 10.152.1.230 ether5" @@ -79,8 +79,8 @@ parsed_sample: - check_gateway: "" comment: "" distance: "100" - dst_address: "10.0.0.0" - dst_address_subnet: "8" + destination_address: "10.0.0.0" + destination_address_subnet: "8" flags: "A SB" gateway: "" gateway_status: ""