From 161e8181bbbcc7411f69e5e057f9d9ff3fe6a95c Mon Sep 17 00:00:00 2001 From: pskliarenko <“pskliarenko@bsh.ru”> Date: Sun, 10 Sep 2023 22:52:59 +0400 Subject: [PATCH] Template + test --- ntc_templates/templates/index | 1 + ...tik_routeros_ip_route_print_detail.textfsm | 22 ++++ ...ikrotik_routeros_ip_route_print_detail.raw | 15 +++ ...ikrotik_routeros_ip_route_print_detail.yml | 100 ++++++++++++++++++ 4 files changed, 138 insertions(+) create mode 100644 ntc_templates/templates/mikrotik_routeros_ip_route_print_detail.textfsm create mode 100644 tests/mikrotik_routeros/ip_route_print_detail/mikrotik_routeros_ip_route_print_detail.raw create mode 100644 tests/mikrotik_routeros/ip_route_print_detail/mikrotik_routeros_ip_route_print_detail.yml diff --git a/ntc_templates/templates/index b/ntc_templates/templates/index index 3a5b516184..1ff14ee522 100644 --- a/ntc_templates/templates/index +++ b/ntc_templates/templates/index @@ -574,6 +574,7 @@ mikrotik_routeros_snmp_community_print_without-paging.textfsm, .*, mikrotik_rout 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 mikrotik_routeros_system_routerboard_print.textfsm, .*, mikrotik_routeros, [[/]]system routerboard print +mikrotik_routeros_ip_route_print_detail.textfsm, .*, mikrotik_routeros, [[/]]ip r[[oute]] p[[rint]] d[[etail]] mikrotik_routeros_ip_route_print_terse.textfsm, .*, mikrotik_routeros, [[/]]ip(v6)? route print terse paloalto_panos_show_running_security-policy.textfsm, .*, paloalto_panos, sh[[ow]] runn[[ing]] security[[-policy]] diff --git a/ntc_templates/templates/mikrotik_routeros_ip_route_print_detail.textfsm b/ntc_templates/templates/mikrotik_routeros_ip_route_print_detail.textfsm new file mode 100644 index 0000000000..4bf3b558e6 --- /dev/null +++ b/ntc_templates/templates/mikrotik_routeros_ip_route_print_detail.textfsm @@ -0,0 +1,22 @@ +Value NUMBER (\d+) +Value COMMENT (.*?) +Value ACTIVE (.) +Value DYNAMIC (.) +Value PROTOCOL (.) +Value DISCARD_PACKET (.) +Value Required NETWORK (\S+) +Value MASK (\d{1,2}) +Value PREF_SRC (\S+) +Value GATEWAY (\S+) +Value GATEWAY_STATUS (.+?(?=[^\=]\S+\=)) +Value CHECK_GATEWAY (\S+) +Value DISTANCE (\d+) +Value TYPE (\S+) + +Start + ^\s*Flags:\s+X\s+-\s+disabled,\s+A\s+-\s+active,\s+D\s+-\s+dynamic,\s+C\s+-\s+connect,\s+S\s+-\s+static,\s+r\s+-\s+rip,\s+b\s+-\s+bgp,\s+o\s+-\s+ospf,\s+m\s+-\s+mme,\s+B\s+-\s+blackhole,\s+U\s+-\s+unreachable,\s+P\s+-\s+prohibit\s*$$ + ^\s*${NUMBER}\s+${ACTIVE}${DYNAMIC}${PROTOCOL}${DISCARD_PACKET}\s+dst-address=${NETWORK}/${MASK}(?:\s+pref-src=${PREF_SRC})?(?:\s+gateway\=${GATEWAY})?(?:\s+gateway-status=${GATEWAY_STATUS})?.*?(?:\s+check-gateway=${CHECK_GATEWAY})?\s+distance=${DISTANCE}.*?(\s+ospf-type=${TYPE})?.*$$ -> Record + ^\s*${NUMBER}\s+${ACTIVE}${DYNAMIC}${PROTOCOL}${DISCARD_PACKET}\s+;{3}\s*${COMMENT}\s*$$ + ^\s*dst-address=${NETWORK}/${MASK}(?:\s+pref-src=${PREF_SRC})?(?:\s+gateway\=${GATEWAY})?(?:\s+gateway-status=${GATEWAY_STATUS})?.*?(?:\s+check-gateway=${CHECK_GATEWAY})?\s+distance=${DISTANCE}.*?(\s+ospf-type=${TYPE})?.*$$ -> Record + ^\s*$$ + ^. -> Error diff --git a/tests/mikrotik_routeros/ip_route_print_detail/mikrotik_routeros_ip_route_print_detail.raw b/tests/mikrotik_routeros/ip_route_print_detail/mikrotik_routeros_ip_route_print_detail.raw new file mode 100644 index 0000000000..3785cb4180 --- /dev/null +++ b/tests/mikrotik_routeros/ip_route_print_detail/mikrotik_routeros_ip_route_print_detail.raw @@ -0,0 +1,15 @@ +Flags: X - disabled, A - active, D - dynamic, C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme, B - blackhole, U - unreachable, P - prohibit + 0 ADS 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 dst-address=10.213.20.64/32 gateway=10.160.1.229 gateway-status=10.160.1.229 reachable via ether1 distance=1 scope=30 target-scope=10 + + 3 A S ;;; to Internet + dst-address=0.0.0.0/0 gateway=10.160.1.230 gateway-status=10.160.1.230 reachable via ether2 distance=1 scope=30 target-scope=10 routing-mark=to-reserve + + 4 A S dst-address=0.0.0.0/0 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 + + 5 A SB dst-address=10.0.0.0/8 type=blackhole distance=100 routing-mark=Free_Wi-Fi + + 6 A S dst-address=0.0.0.0/0 gateway=1.2.3.4 gateway-status=1.2.3.4 recursive via 10.152.1.230 ether5 check-gateway=ping distance=1 scope=30 target-scope=10 diff --git a/tests/mikrotik_routeros/ip_route_print_detail/mikrotik_routeros_ip_route_print_detail.yml b/tests/mikrotik_routeros/ip_route_print_detail/mikrotik_routeros_ip_route_print_detail.yml new file mode 100644 index 0000000000..e7dab402d2 --- /dev/null +++ b/tests/mikrotik_routeros/ip_route_print_detail/mikrotik_routeros_ip_route_print_detail.yml @@ -0,0 +1,100 @@ +--- +parsed_sample: + - active: "A" + check_gateway: "" + comment: "" + discard_packet: " " + distance: "2" + dynamic: "D" + gateway: "192.168.8.1" + gateway_status: "192.168.8.1 reachable via lte1" + mask: "0" + network: "0.0.0.0" + number: "0" + pref_src: "" + protocol: "S" + type: "" + - active: "A" + check_gateway: "" + comment: "" + discard_packet: " " + distance: "0" + dynamic: "D" + gateway: "ether1" + gateway_status: "ether1 reachable" + mask: "30" + network: "10.160.1.228" + number: "1" + pref_src: "10.160.1.230" + protocol: "C" + type: "" + - active: "A" + check_gateway: "" + comment: "" + discard_packet: " " + distance: "1" + dynamic: " " + gateway: "10.160.1.229" + gateway_status: "10.160.1.229 reachable via ether1" + mask: "32" + network: "10.213.20.64" + number: "2" + pref_src: "" + protocol: "S" + type: "" + - active: "A" + check_gateway: "" + comment: "to Internet" + discard_packet: " " + distance: "1" + dynamic: " " + gateway: "10.160.1.230" + gateway_status: "10.160.1.230 reachable via ether2" + mask: "0" + network: "0.0.0.0" + number: "3" + pref_src: "" + protocol: "S" + type: "" + - active: "A" + check_gateway: "" + comment: "" + discard_packet: " " + distance: "1" + dynamic: " " + gateway: "1.2.3.4" + gateway_status: "1.2.3.4 recursive via 10.152.1.230 ether5" + mask: "0" + network: "0.0.0.0" + number: "4" + pref_src: "" + protocol: "S" + type: "" + - active: "A" + check_gateway: "" + comment: "" + discard_packet: "B" + distance: "100" + dynamic: " " + gateway: "" + gateway_status: "" + mask: "8" + network: "10.0.0.0" + number: "5" + pref_src: "" + protocol: "S" + type: "" + - active: "A" + check_gateway: "ping" + comment: "" + discard_packet: " " + distance: "1" + dynamic: " " + gateway: "1.2.3.4" + gateway_status: "1.2.3.4 recursive via 10.152.1.230 ether5" + mask: "0" + network: "0.0.0.0" + number: "6" + pref_src: "" + protocol: "S" + type: ""