From d821dc183df4657ecfa29df78a9fd34122701d36 Mon Sep 17 00:00:00 2001 From: pskliarenko <“pskliarenko@bsh.ru”> Date: Sun, 10 Sep 2023 23:03:54 +0400 Subject: [PATCH 1/2] Template + test --- ntc_templates/templates/index | 1 + ...tik_routeros_routing_bgp_peer_print_status.textfsm | 11 +++++++++++ ...ikrotik_routeros_routing_bgp_peer_print_status.raw | 3 +++ ...ikrotik_routeros_routing_bgp_peer_print_status.yml | 6 ++++++ 4 files changed, 21 insertions(+) create mode 100644 ntc_templates/templates/mikrotik_routeros_routing_bgp_peer_print_status.textfsm create mode 100644 tests/mikrotik_routeros/routing_bgp_peer_print_status/mikrotik_routeros_routing_bgp_peer_print_status.raw create mode 100644 tests/mikrotik_routeros/routing_bgp_peer_print_status/mikrotik_routeros_routing_bgp_peer_print_status.yml diff --git a/ntc_templates/templates/index b/ntc_templates/templates/index index 3a5b516184..51058bac42 100644 --- a/ntc_templates/templates/index +++ b/ntc_templates/templates/index @@ -572,6 +572,7 @@ mikrotik_routeros_interface_ethernet_monitor_name_once.textfsm, .*, mikrotik_rou mikrotik_routeros_ip_firewall_address-list_print_terse.textfsm, .*, mikrotik_routeros, [[/]]ip(v6)? firewall address-list print terse 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_routing_bgp_peer_print_status.textfsm, .*, mikrotik_routeros, [[/]]r[[outing]] bg[[p]] p[[eer]] p[[rint]] s[[tatus]] 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_terse.textfsm, .*, mikrotik_routeros, [[/]]ip(v6)? route print terse diff --git a/ntc_templates/templates/mikrotik_routeros_routing_bgp_peer_print_status.textfsm b/ntc_templates/templates/mikrotik_routeros_routing_bgp_peer_print_status.textfsm new file mode 100644 index 0000000000..ff1e633590 --- /dev/null +++ b/ntc_templates/templates/mikrotik_routeros_routing_bgp_peer_print_status.textfsm @@ -0,0 +1,11 @@ +Value BGP_NEIGH (\S+) +Value NEIGH_AS (\d+) +Value UP_DOWN (\S+) +Value STATE (\S+) + +Start + ^\s*Flags:\s+X\s+-\s+disabled,\s+E\s+-\s+established\s*$$ + ^.*remote-address=${BGP_NEIGH}.*remote-as=${NEIGH_AS}.*(?:uptime=${UP_DOWN})?.*$$ + ^.*state=${STATE}.*$$ -> Record + ^\s*$$ + ^. -> Error diff --git a/tests/mikrotik_routeros/routing_bgp_peer_print_status/mikrotik_routeros_routing_bgp_peer_print_status.raw b/tests/mikrotik_routeros/routing_bgp_peer_print_status/mikrotik_routeros_routing_bgp_peer_print_status.raw new file mode 100644 index 0000000000..f983bf770f --- /dev/null +++ b/tests/mikrotik_routeros/routing_bgp_peer_print_status/mikrotik_routeros_routing_bgp_peer_print_status.raw @@ -0,0 +1,3 @@ +Flags: X - disabled, E - established + 0 name="peer1" instance=default remote-address=192.168.1.134 remote-as=65001 tcp-md5-key="" nexthop-choice=default multihop=no route-reflect=no hold-time=3m + ttl=255 in-filter="" out-filter="" address-families=ip,ipv6 default-originate=never remove-private-as=no as-override=no passive=no use-bfd=no state=opensent diff --git a/tests/mikrotik_routeros/routing_bgp_peer_print_status/mikrotik_routeros_routing_bgp_peer_print_status.yml b/tests/mikrotik_routeros/routing_bgp_peer_print_status/mikrotik_routeros_routing_bgp_peer_print_status.yml new file mode 100644 index 0000000000..177b06e073 --- /dev/null +++ b/tests/mikrotik_routeros/routing_bgp_peer_print_status/mikrotik_routeros_routing_bgp_peer_print_status.yml @@ -0,0 +1,6 @@ +--- +parsed_sample: + - bgp_neigh: "192.168.1.134" + neigh_as: "65001" + state: "opensent" + up_down: "" From 7851dc3e63e36fe2e7b03b1f957a4de69a76f51e Mon Sep 17 00:00:00 2001 From: Jacob McGill <9847006+jmcgill298@users.noreply.github.com> Date: Mon, 22 Jul 2024 15:19:09 -0400 Subject: [PATCH 2/2] Apply suggestions from code review --- .../mikrotik_routeros_routing_bgp_peer_print_status.textfsm | 6 +++--- .../mikrotik_routeros_routing_bgp_peer_print_status.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ntc_templates/templates/mikrotik_routeros_routing_bgp_peer_print_status.textfsm b/ntc_templates/templates/mikrotik_routeros_routing_bgp_peer_print_status.textfsm index ff1e633590..a157fcedc0 100644 --- a/ntc_templates/templates/mikrotik_routeros_routing_bgp_peer_print_status.textfsm +++ b/ntc_templates/templates/mikrotik_routeros_routing_bgp_peer_print_status.textfsm @@ -1,11 +1,11 @@ -Value BGP_NEIGH (\S+) -Value NEIGH_AS (\d+) +Value BGP_NEIGHBOR (\S+) +Value NEIGHBOR_AS (\d+) Value UP_DOWN (\S+) Value STATE (\S+) Start ^\s*Flags:\s+X\s+-\s+disabled,\s+E\s+-\s+established\s*$$ - ^.*remote-address=${BGP_NEIGH}.*remote-as=${NEIGH_AS}.*(?:uptime=${UP_DOWN})?.*$$ + ^.*remote-address=${BGP_NEIGHBOR}.*remote-as=${NEIGHBOR_AS}.*(?:uptime=${UP_DOWN})?.*$$ ^.*state=${STATE}.*$$ -> Record ^\s*$$ ^. -> Error diff --git a/tests/mikrotik_routeros/routing_bgp_peer_print_status/mikrotik_routeros_routing_bgp_peer_print_status.yml b/tests/mikrotik_routeros/routing_bgp_peer_print_status/mikrotik_routeros_routing_bgp_peer_print_status.yml index 177b06e073..815f33953a 100644 --- a/tests/mikrotik_routeros/routing_bgp_peer_print_status/mikrotik_routeros_routing_bgp_peer_print_status.yml +++ b/tests/mikrotik_routeros/routing_bgp_peer_print_status/mikrotik_routeros_routing_bgp_peer_print_status.yml @@ -1,6 +1,6 @@ --- parsed_sample: - - bgp_neigh: "192.168.1.134" - neigh_as: "65001" + - bgp_neighbor: "192.168.1.134" + neighbor_as: "65001" state: "opensent" up_down: ""