From db6949d5e68851b602e3b67a0bc1aca5c384ab94 Mon Sep 17 00:00:00 2001 From: pskliarenko <“pskliarenko@bsh.ru”> Date: Sun, 10 Sep 2023 22:43:50 +0400 Subject: [PATCH 1/2] Template + test --- ...inet_get_router_info_bgp_neighbors.textfsm | 67 ++++++++++++++ ntc_templates/templates/index | 1 + ...fortinet_get_router_info_bgp_neighbors.raw | 92 +++++++++++++++++++ ...fortinet_get_router_info_bgp_neighbors.yml | 70 ++++++++++++++ 4 files changed, 230 insertions(+) create mode 100644 ntc_templates/templates/fortinet_get_router_info_bgp_neighbors.textfsm create mode 100644 tests/fortinet/get_router_info_bgp_neighbors/fortinet_get_router_info_bgp_neighbors.raw create mode 100644 tests/fortinet/get_router_info_bgp_neighbors/fortinet_get_router_info_bgp_neighbors.yml diff --git a/ntc_templates/templates/fortinet_get_router_info_bgp_neighbors.textfsm b/ntc_templates/templates/fortinet_get_router_info_bgp_neighbors.textfsm new file mode 100644 index 0000000000..5d49d9bf9d --- /dev/null +++ b/ntc_templates/templates/fortinet_get_router_info_bgp_neighbors.textfsm @@ -0,0 +1,67 @@ +Value NEIGHBOR (\S+) +Value BGP_VERSION (\d+) +Value REMOTE_ASN (\d+) +Value LOCAL_ASN (\d+) +Value REMOTE_ROUTER_ID (\S+) +Value BGP_STATE ([\w\s\(\)]+) +Value UPTIME (\S+) +Value List ADDR_FAMILY (\w+(?:\s+\w+)?) +Value List TABLE_VERSION (\d+) +Value List NEI_TABLE_VERSION (\d+) +Value List INBOUND_ROUTEMAP (\S+) +Value List OUTBOUND_ROUTEMAP (\S+) +Value List ACCEPTED_PREFIXES (\d+) +Value List ACCEPTED_PREFIXES_RIB (\d+) +Value List ANNOUNCED_PREFIXES (\d+) +Value LOCALHOST_IP (\S+) +Value LOCALHOST_PORT (\d+) +Value REMOTE_IP (\S+) +Value REMOTE_PORT (\d+) +Value NEXTHOP_IP (\S+) +Value NEXTHOP_INTERFACE (\S+) + +Start + ^VRF\s+\d+\s+neighbor\s+table:\s*$$ + ^BGP\s+neighbor\s+is -> Continue.Record + ^BGP\s+neighbor\s+is\s+${NEIGHBOR},\s+remote\s+AS\s+${REMOTE_ASN},\s+local\s+AS\s+${LOCAL_ASN},.*$$ + ^\s+BGP\s+version\s+${BGP_VERSION},\s+remote\s+router\s+ID\s+${REMOTE_ROUTER_ID}\s*$$ + ^\s+BGP\s+state\s+=\s+${BGP_STATE},\s+\w+\s+for\s+${UPTIME}\s*$$ + ^\s+Last\s+read\s+\d{2}:\d{2}:\d{2},\s+hold\s+time\s+is\s+\d+,\s+keepalive\s+interval\s+is\s+\d+\s+seconds\s*$$ + ^\s+Configured\s+hold\s+time\s+is\s+\d+,\s+keepalive\s+interval\s+is\s+\d+\s+seconds\s*$$ + ^\s+Neighbor\s+capabilities:\s*$$ + ^\s+Route\s+refresh:\s+.*$$ + ^\s+Address\s+family\s+IPv4\s+Unicast:\s+.*$$ + ^\s+Address\s+family\s+IPv6\s+Unicast:\s+.*$$ + ^\s+Received\s+\d+\s+messages,\s+\d+\s+notifications,\s+\d+\s+in\s+queue\s*$$ + ^\s+Sent\s+\d+\s+messages,\s+\d+\s+notifications,\s+\d+\s+in\s+queue\s*$$ + ^\s+Route\s+refresh\s+request:\s+received\s+\d+,\s+sent\s+\d+\s*$$ + ^\s+Minimum\s+time\s+between\s+advertisement\s+runs\s+is\s+\d+\s+seconds\s*$$ + ^\s+For\s+address\s+family:\s+${ADDR_FAMILY}\s*$$ -> AddrFamState + ^\s+Connections\s+established\s+\d+;\s+dropped\s+\d+\s*$$ + ^Local\s+host:\s+${LOCALHOST_IP},\s+Local port:\s+${LOCALHOST_PORT}\s*$$ + ^Foreign\s+host:\s+${REMOTE_IP},\s+Foreign port:\s+${REMOTE_PORT}\s*$$ + ^Nexthop:\s+${NEXTHOP_IP}\s*$$ + ^Nexthop\s+interface:\s+${NEXTHOP_INTERFACE}\s*$$ + ^Nexthop\s+global:\s+.*$$ + ^Nexthop\s+local:\s+.*$$ + ^BGP\s+connection:\s+.*$$ + ^Last\s+Reset:\s+\S+,\s+.*$$ + ^Notification\s+Error\s+Message:\s+.*$$ + ^\s*$$ + ^. -> Error + +AddrFamState + ^\s+BGP\s+table\s+version\s+${TABLE_VERSION},\s+neighbor\s+version\s+${NEI_TABLE_VERSION}\s*$$ + ^\s+Index\s+\d+,\s+Offset\s+\d+,\s+Mask\s+\w+\s*$$ + ^\s+Additional\s+Path:\s*$$ + ^\s+Send-mode:\s+.*$$ + ^\s+Receive-mode:\s+.*$$ + ^\s+NEXT_HOP\s+is\s+always\s+this\s+router\s*$$ + ^\s+Community\s+attribute\s+sent\s+to\s+this\s+neighbor.*$$ + ^\s+Inbound\s+path\s+policy\s+configured\s*$$ + ^\s+Route\s+map\s+for\s+incoming\s+advertisements\s+is\s+${INBOUND_ROUTEMAP}\s*$$ + ^\s+Route\s+map\s+for\s+outgoing\s+advertisements\s+is\s+${OUTBOUND_ROUTEMAP}\s*$$ + ^\s+${ACCEPTED_PREFIXES}\saccepted\sprefixes,\s${ACCEPTED_PREFIXES_RIB}\sprefixes\sin\srib\s*$$ + ^\s+${ANNOUNCED_PREFIXES}\sannounced\sprefixes\s*$$ -> Start + ^\s*$$ + ^. -> Error diff --git a/ntc_templates/templates/index b/ntc_templates/templates/index index 3a5b516184..827ad9055a 100644 --- a/ntc_templates/templates/index +++ b/ntc_templates/templates/index @@ -481,6 +481,7 @@ ericsson_ipos_show_isis_adjacency.textfsm, .*, ericsson_ipos, sh[[ow]] isis adja ericsson_ipos_show_version.textfsm, .*, ericsson_ipos, sh[[ow]] ver[[sion]] ericsson_ipos_show_arp.textfsm, .*, ericsson_ipos, sh[[ow]] ar[[p]] +fortinet_get_router_info_bgp_neighbors.textfsm, .*, fortinet, g[[et]] r[[outer]] info bg[[p]] nei[[ghbors]] fortinet_get_system_interface_physical.textfsm, .*, fortinet, g[[et]] sy[[stem]] in[[terface]] p[[hysical]] 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]] diff --git a/tests/fortinet/get_router_info_bgp_neighbors/fortinet_get_router_info_bgp_neighbors.raw b/tests/fortinet/get_router_info_bgp_neighbors/fortinet_get_router_info_bgp_neighbors.raw new file mode 100644 index 0000000000..a462433974 --- /dev/null +++ b/tests/fortinet/get_router_info_bgp_neighbors/fortinet_get_router_info_bgp_neighbors.raw @@ -0,0 +1,92 @@ +VRF 0 neighbor table: +BGP neighbor is 10.105.1.254, remote AS 65400, local AS 65400, internal link + BGP version 4, remote router ID 10.105.3.254 + BGP state = Established, up for 4d14h28m + Last read 00:00:00, hold time is 3, keepalive interval is 1 seconds + Configured hold time is 3, keepalive interval is 1 seconds + Neighbor capabilities: + Route refresh: advertised and received (old and new) + Address family IPv4 Unicast: advertised and received + Address family IPv6 Unicast: advertised and received + Received 1517339 messages, 2 notifications, 0 in queue + Sent 1482858 messages, 6 notifications, 0 in queue + Route refresh request: received 0, sent 0 + Minimum time between advertisement runs is 1 seconds + + For address family: IPv4 Unicast + BGP table version 31, neighbor version 25 + Index 1, Offset 0, Mask 0x2 + Additional Path: + Send-mode: received + Receive-mode: advertised + NEXT_HOP is always this router + Community attribute sent to this neighbor (both) + Inbound path policy configured + Route map for incoming advertisements is *prefer_vpn1root + 423 accepted prefixes, 423 prefixes in rib + 3 announced prefixes + + For address family: IPv6 Unicast + BGP table version 1, neighbor version 1 + Index 1, Offset 0, Mask 0x2 + Community attribute sent to this neighbor (both) + 0 accepted prefixes, 0 prefixes in rib + 0 announced prefixes + + Connections established 9; dropped 8 +Local host: 10.105.1.2, Local port: 3777 +Foreign host: 10.105.1.254, Foreign port: 179 +Nexthop: 10.105.1.2 +Nexthop interface: VPN1_0 +Nexthop global: :: +Nexthop local: :: +BGP connection: non shared network +Last Reset: 4d14h38m, due to BGP Notification sent +Notification Error Message: (Hold Timer Expired/Unspecified Error Subcode) + +BGP neighbor is 10.105.2.254, remote AS 65400, local AS 65400, internal link + BGP version 4, remote router ID 10.105.3.254 + BGP state = Established, up for 12:41:52 + Last read 00:00:00, hold time is 3, keepalive interval is 1 seconds + Configured hold time is 3, keepalive interval is 1 seconds + Neighbor capabilities: + Route refresh: advertised and received (old and new) + Address family IPv4 Unicast: advertised and received + Address family IPv6 Unicast: advertised and received + Received 1517182 messages, 4 notifications, 0 in queue + Sent 1481876 messages, 16 notifications, 0 in queue + Route refresh request: received 0, sent 0 + Minimum time between advertisement runs is 1 seconds + + For address family: IPv4 Unicast + BGP table version 31, neighbor version 30 + Index 2, Offset 0, Mask 0x4 + Additional Path: + Send-mode: received + Receive-mode: advertised + NEXT_HOP is always this router + Community attribute sent to this neighbor (both) + Inbound path policy configured + Route map for incoming advertisements is *prefer_vpn2root + 423 accepted prefixes, 423 prefixes in rib + 3 announced prefixes + + For address family: IPv6 Unicast + BGP table version 1, neighbor version 1 + Index 2, Offset 0, Mask 0x4 + Community attribute sent to this neighbor (both) + 0 accepted prefixes, 0 prefixes in rib + 0 announced prefixes + + Connections established 21; dropped 20 +Local host: 10.105.2.2, Local port: 21489 +Foreign host: 10.105.2.254, Foreign port: 179 +Nexthop: 10.105.2.2 +Nexthop interface: VPN2_0 +Nexthop global: :: +Nexthop local: :: +BGP connection: non shared network +Last Reset: 12:55:18, due to BGP Notification sent +Notification Error Message: (Hold Timer Expired/Unspecified Error Subcode) + + diff --git a/tests/fortinet/get_router_info_bgp_neighbors/fortinet_get_router_info_bgp_neighbors.yml b/tests/fortinet/get_router_info_bgp_neighbors/fortinet_get_router_info_bgp_neighbors.yml new file mode 100644 index 0000000000..2f4bb9c2e7 --- /dev/null +++ b/tests/fortinet/get_router_info_bgp_neighbors/fortinet_get_router_info_bgp_neighbors.yml @@ -0,0 +1,70 @@ +--- +parsed_sample: + - accepted_prefixes: + - "423" + - "0" + accepted_prefixes_rib: + - "423" + - "0" + addr_family: + - "IPv4 Unicast" + - "IPv6 Unicast" + announced_prefixes: + - "3" + - "0" + bgp_state: "Established" + bgp_version: "4" + inbound_routemap: + - "*prefer_vpn1root" + local_asn: "65400" + localhost_ip: "10.105.1.2" + localhost_port: "3777" + nei_table_version: + - "25" + - "1" + neighbor: "10.105.1.254" + nexthop_interface: "VPN1_0" + nexthop_ip: "10.105.1.2" + outbound_routemap: [] + remote_asn: "65400" + remote_ip: "10.105.1.254" + remote_port: "179" + remote_router_id: "10.105.3.254" + table_version: + - "31" + - "1" + uptime: "4d14h28m" + - accepted_prefixes: + - "423" + - "0" + accepted_prefixes_rib: + - "423" + - "0" + addr_family: + - "IPv4 Unicast" + - "IPv6 Unicast" + announced_prefixes: + - "3" + - "0" + bgp_state: "Established" + bgp_version: "4" + inbound_routemap: + - "*prefer_vpn2root" + local_asn: "65400" + localhost_ip: "10.105.2.2" + localhost_port: "21489" + nei_table_version: + - "30" + - "1" + neighbor: "10.105.2.254" + nexthop_interface: "VPN2_0" + nexthop_ip: "10.105.2.2" + outbound_routemap: [] + remote_asn: "65400" + remote_ip: "10.105.2.254" + remote_port: "179" + remote_router_id: "10.105.3.254" + table_version: + - "31" + - "1" + uptime: "12:41:52" From ebf0efb1549ab2d8a0d93a9381e4573e299843a1 Mon Sep 17 00:00:00 2001 From: pskliarenko <“pskliarenko@bsh.ru”> Date: Tue, 12 Sep 2023 12:15:57 +0400 Subject: [PATCH 2/2] Add empty neighbors check --- .../templates/fortinet_get_router_info_bgp_neighbors.textfsm | 1 + .../fortinet_get_router_info_bgp_neighbors_empty.raw | 0 .../fortinet_get_router_info_bgp_neighbors_empty.yml | 2 ++ 3 files changed, 3 insertions(+) create mode 100644 tests/fortinet/get_router_info_bgp_neighbors/fortinet_get_router_info_bgp_neighbors_empty.raw create mode 100644 tests/fortinet/get_router_info_bgp_neighbors/fortinet_get_router_info_bgp_neighbors_empty.yml diff --git a/ntc_templates/templates/fortinet_get_router_info_bgp_neighbors.textfsm b/ntc_templates/templates/fortinet_get_router_info_bgp_neighbors.textfsm index 5d49d9bf9d..5071461c73 100644 --- a/ntc_templates/templates/fortinet_get_router_info_bgp_neighbors.textfsm +++ b/ntc_templates/templates/fortinet_get_router_info_bgp_neighbors.textfsm @@ -47,6 +47,7 @@ Start ^BGP\s+connection:\s+.*$$ ^Last\s+Reset:\s+\S+,\s+.*$$ ^Notification\s+Error\s+Message:\s+.*$$ + ^\s*\%\s+No\s+neighbor\s+exist\s*$$ ^\s*$$ ^. -> Error diff --git a/tests/fortinet/get_router_info_bgp_neighbors/fortinet_get_router_info_bgp_neighbors_empty.raw b/tests/fortinet/get_router_info_bgp_neighbors/fortinet_get_router_info_bgp_neighbors_empty.raw new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/fortinet/get_router_info_bgp_neighbors/fortinet_get_router_info_bgp_neighbors_empty.yml b/tests/fortinet/get_router_info_bgp_neighbors/fortinet_get_router_info_bgp_neighbors_empty.yml new file mode 100644 index 0000000000..e77add67ed --- /dev/null +++ b/tests/fortinet/get_router_info_bgp_neighbors/fortinet_get_router_info_bgp_neighbors_empty.yml @@ -0,0 +1,2 @@ +--- +parsed_sample: []