Skip to content

Commit

Permalink
Merge branch 'ntc_update' into 'master'
Browse files Browse the repository at this point in the history
Support unknown protocol in arista_eos_show_interfaces_description (networktocode#1540)

See merge request bsh-developers/ntc-templates!40
  • Loading branch information
Скляренко Павел committed Nov 7, 2023
2 parents f6979f0 + 38292dd commit 8a1a898
Show file tree
Hide file tree
Showing 29 changed files with 1,131 additions and 77 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
tox.ini
.nox/
.coverage
.coverage.*
Expand Down
12 changes: 6 additions & 6 deletions ntc_templates/templates/arista_eos_show_ip_bgp.textfsm
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ Value LOCAL_PREF (\S+)
Value WEIGHT (\S+)
Value AS_PATH (.*?)
Value ORIGIN ([ie\?])
Value Filldown VRF (\S+)
Value Filldown LOCAL_AS (\d+\.\d+|\d+)
Value Filldown ROUTER_ID (\S+)

Start
# Since using mostly position, play it safe and ensure we see header first
^AS Path Attributes.+ -> Bgp_table

Bgp_table
# Example:
# * 0.0.0.0/0 100.100.10.226 0 350 0 65000 65000 65000 64810 64800 i
^BGP\s+routing\s+table\s+information\s+for\s+VRF\s+${VRF}
^Router\s+identifier\s+${ROUTER_ID},\s+local\s+AS\s+number\s+${LOCAL_AS}
^AS Path Attributes.+
^\s${STATUS}${PATH_SELECTION}${ROUTE_SOURCE}\s+${NETWORK}\s+${NEXT_HOP}\s+${METRIC}\s+${LOCAL_PREF}\s+${WEIGHT}\s+${AS_PATH}\s+${ORIGIN}$$ -> Record

EOF
7 changes: 3 additions & 4 deletions ntc_templates/templates/arista_eos_show_ip_bgp_detail.textfsm
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ Value COMMUNITY ((?:(?:(?:no-export|no-advertise|local-as|internet)|\d+\s?:\s?\d
Value NEXT_HOP (\d+\.\d+\.\d+\.\d+)
Value NEIGHBOR (\S+)
Value NEIGHBOR_ID (\S+)
Value Filldown VRF (\S+)
Value Filldown ROUTER_ID (\S+)
Value Filldown LOCAL_AS (\S+)
Value METRIC (\d+)

Start
^BGP\s+routing\s+table\sinformation.+
^Router\s+identifier\s+${ROUTER_ID},\s+local\s+AS\s+number\s+${LOCAL_AS} -> Path

Path
^BGP\s+routing\s+table\sinformation\s+for\s+VRF\s+${VRF}
^Router\s+identifier\s+${ROUTER_ID},\s+local\s+AS\s+number\s+${LOCAL_AS}
^BGP\s+routing\s+table\s+entry\s+for\s+${PREFIX}(?:/${PREFIX_LENGTH})?
^\s+Paths:\s+\d+\s+available
^\s+${AS_PATH}\s*$$
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Value Filldown,Required SESSION_TYPE (\S+)
Value USERNAME (\S+)
Value Required INDEX (\d+)
Value ASSIGNED_IP (\d+\.\d+\.\d+\.\d+)
Value PUBLIC_IP (\S+)
Value ASSIGNED_IPV6 (\S+)
Value PROTOCOL (.+?)
Value LICENSE (.+?)
Value ENCRYPTION (.+?)
Value HASHING (.+?)
Value BYTES_TX (\d+)
Value BYTES_RX (\d+)
Value GROUP_POLICY (\S+)
Value TUNNEL_GROUP (\S+)
Value LOGIN_TIME (\d+:\d+:\d+)
Value LOGIN_TIME_ZONE (\S+)
Value LOGIN_WEEKDAY (\w+)
Value LOGIN_MONTH (\w+)
Value LOGIN_DAY (\d+)
Value LOGIN_YEAR (\d+)
Value DURATION (.+?)
Value INACTIVITY (.+?)
Value VLAN_MAPPING (\S+)
Value VLAN_ID (.+?)
Value AUDT_SESS_ID (.+?)
Value SECURITY_GRP (\S+)
Value TUNNEL_ZONE (\d+)

Start
^Session\s+Type:\s+${SESSION_TYPE}$$ -> Connection

Connection
^\s*Username\s*:\s+${USERNAME}\s+Index\s+:\s*${INDEX}$$
^\s*Username\s*:\s+${USERNAME}$$
^\s*Index\s*:\s+${INDEX}$$
^\s*Assigned\s+IP\s*:\s+${ASSIGNED_IP}\s+Public\s*IP\s*:\s*${PUBLIC_IP}$$
^\s*Assigned\s+IP\s*:\s+${ASSIGNED_IP}$$
^\s*Assigned\s+IPv6\s*:\s+${ASSIGNED_IPV6}$$
^\s*Public\s+IP\s*:\s+${PUBLIC_IP}$$
^\s*Protocol\s+:\s+${PROTOCOL}$$
^\s*License\s+:\s*${LICENSE}$$
^\s*Encryption\s+:\s*${ENCRYPTION}$$
^\s*Hashing\s+:\s*${HASHING}$$
^\s*Bytes\s+Tx\s+:\s+${BYTES_TX}\s+Bytes\s+Rx\s+:\s+${BYTES_RX}$$
^\s*Group\s+Policy\s+:\s+${GROUP_POLICY}\s+Tunnel\s+Group\s+:\s+${TUNNEL_GROUP}$$
^\s*Group\s+Policy\s+:\s+${GROUP_POLICY}$$
^\s*Tunnel\s+Group\s+:\s+${TUNNEL_GROUP}$$
^\s*Login\s+Time\s+:\s+${LOGIN_TIME}\s+${LOGIN_TIME_ZONE}\s+${LOGIN_WEEKDAY}\s+${LOGIN_MONTH}\s+${LOGIN_DAY}\s+${LOGIN_YEAR}$$
^\s*Duration\s+:\s+${DURATION}$$
^\s*Inactivity\s+:\s+${INACTIVITY}$$
^\s*VLAN\s+Mapping\s+:\s+${VLAN_MAPPING}\s+VLAN\s+:\s+${VLAN_ID}$$
^\s*Audt\s+Sess\s+ID\s+:\s+${AUDT_SESS_ID}$$
^\s*Security\s+Grp\s+:\s+${SECURITY_GRP}\s+Tunnel\s+Zone\s+:\s+${TUNNEL_ZONE}$$ -> Record
^\s*$$
^. -> Error
13 changes: 13 additions & 0 deletions ntc_templates/templates/cisco_ios_show_ap_cdp_neighbors.textfsm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Value AP_NAME (\S+)
Value AP_IP ([a-fA-F0-9:\.]+)
Value NEIGHBOR_NAME (\S+)
Value NEIGHBOR_IP ([a-fA-F0-9:\.]+)
Value NEIGHBOR_PORT ([a-zA-Z0-9\/\.]+)

Start
^[a-zA-Z]+\s[a-z]+\s[a-zA-z]+:\s\d+$$
^AP\sName\s+AP\sIP\s+Neighbor\sName\s+Neighbor\sIP\s+Neighbor\sPort\s*$$
^-+\s*$$
^${AP_NAME}\s+${AP_IP}\s+${NEIGHBOR_NAME}\s+${NEIGHBOR_IP}\s+${NEIGHBOR_PORT}\s*$$ -> Record
^\s*$$
^. -> Error
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
# Status: s-suppressed, x-deleted, S-stale, d-dampened, h-history, *-valid, >-best
Value STATUS ([sxSdh*])
# ? \| multipath
Value PATH_SELECTION ([> |])
# Path type: i-internal, e-external, c-confed, l-local, a-aggregate, r-redist, I-injected
Value ROUTE_SOURCE ([ieclarI])
Value Filldown NETWORK ([A-Fa-f0-9:\.]+\/\d+)
Value Filldown PREFIX ([A-Fa-f0-9:\.]+)
Value Filldown PREFIX_LENGTH (\d+)
Value NEXT_HOP ([A-Fa-f0-9:\.]+)
Value METRIC (\d+)
Value LOCAL_PREF (\d+)
Value WEIGHT (\d+)
Value AS_PATH ((\d+|\{\d+)(\.\d+?|\s.*?)*)
# Origin codes: i - IGP, e - EGP, ? - incomplete, | - multipath, & - backup
Value ORIGIN ([ie\?\|&])


Start
^Can't\s+find\s+neighbor
^Peer\s+
Expand All @@ -25,18 +21,17 @@ Start
^. -> Error

Bgp_table
#
# Match first when there is no network, since previous line had it already (compliment and filldown below)
# Older table format, with blank values parsing not reliable. (cisco_nxos_show_ip_bgp.raw)
# Network Next Hop Metric LocPrf Weight Path
# Example: *>e10.10.101.4/30 10.10.2.1 0 64102 i
# Example: *>e 10.10.1.1 0 64101 64002 i
^${STATUS}${PATH_SELECTION}${ROUTE_SOURCE}${NETWORK}(\s{0,12}${NEXT_HOP}\s{4}|\s{20})(\s{2,14}${METRIC}|\s{8})(\s{1,18}${LOCAL_PREF}|\s{8})(\s{1,22}${WEIGHT})(\s${AS_PATH})?\s${ORIGIN}$$ -> Record
^${STATUS}${PATH_SELECTION}${ROUTE_SOURCE}${PREFIX}/${PREFIX_LENGTH}(\s{0,12}${NEXT_HOP}\s{4}|\s{20})(\s{2,14}${METRIC}|\s{8})(\s{1,18}${LOCAL_PREF}|\s{8})(\s{1,22}${WEIGHT})(\s${AS_PATH})?\s${ORIGIN}$$ -> Record
^${STATUS}${PATH_SELECTION}${ROUTE_SOURCE}\s\s\s{16}(\s{0,12}${NEXT_HOP}\s{4}|\s{20})(\s{2,14}${METRIC}|\s{8})(\s{1,18}${LOCAL_PREF}|\s{8})(\s{1,22}${WEIGHT})(\s${AS_PATH})?\s${ORIGIN}$$ -> Record
#
# Match newer format (cisco_nxos_show_ip_bgp1.raw)
# Example: * e0.0.0.0/0 1.2.3.4 4294967295 0 12345.102
^${STATUS}${PATH_SELECTION}${ROUTE_SOURCE}${NETWORK}\s${NEXT_HOP}\s${METRIC}\s${LOCAL_PREF}\s${WEIGHT}(\s${AS_PATH})?\s${ORIGIN}$$ -> Record
^${STATUS}${PATH_SELECTION}${ROUTE_SOURCE}${PREFIX}/${PREFIX_LENGTH}\s${NEXT_HOP}\s${METRIC}\s${LOCAL_PREF}\s${WEIGHT}(\s${AS_PATH})?\s${ORIGIN}$$ -> Record
^${STATUS}${PATH_SELECTION}${ROUTE_SOURCE}\s${NEXT_HOP}\s${METRIC}\s${LOCAL_PREF}\s${WEIGHT}(\s${AS_PATH})?\s${ORIGIN}$$ -> Record
^. -> Error

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Value NEIGHBOR (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})
Value PEER_GROUP (\S+)
Value DESCRIPTION (.*)
Value VRF (\S+)
Value ASN (\d+|\d+\.\d+)
Value REMOTE_ASN (\d+|\d+\.\d+)
Value LOCAL_ASN (\d+|\d+\.\d+)
Expand Down Expand Up @@ -62,6 +63,7 @@ Start
^\s+Inherits.+\s${PEER_GROUP}
^\s+Description:\s+${DESCRIPTION}
^\s+BGP state = ${BGP_STATE}, \w+ for ${UPTIME}
^\s+Neighbor\s+vrf:\s+${VRF}
^\s+Using ${SOURCE_IFACE} as [\w\s]+
^\s+[\w\s]+, interface ${SOURCE_IFACE}
^\s+Connections established ${CONN_ESTAB}, dropped ${CONN_DROPPED}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Value Required,Filldown BUNDLE_IFACE (Po\d+)
Value Filldown BUNDLE_STATUS (\(\w+\))
Value Filldown BUNDLE_PROTO (\w+)
Value Filldown BUNDLE_PROTO_STATE (\(\w+\))
Value List PHYS_IFACE (Et.+?)
Value List PHYS_IFACE ([\w\/]+|\-\-)
Value List PHYS_IFACE_STATUS (\(.+?\))


Expand Down Expand Up @@ -43,3 +43,4 @@ CASE2_RTE
^\s{37}Et.+?\s+${PHYS_IFACE}${PHYS_IFACE_STATUS}(\s|$$) -> Continue
^\s{37}Et.+?\s+Et.+?\s+${PHYS_IFACE}${PHYS_IFACE_STATUS}(\s|$$) -> Continue
^\s{37}Et.+?\s+Et.+?\s+Et.+?\s+${PHYS_IFACE}${PHYS_IFACE_STATUS}(\s|$$) -> Continue
^\d+\s+${BUNDLE_IFACE}${BUNDLE_STATUS}\s+\w+\s+${BUNDLE_PROTO}\s+${PHYS_IFACE}($$) -> Next
5 changes: 4 additions & 1 deletion ntc_templates/templates/index
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ cisco_asa_show_nat.textfsm, .*, cisco_asa, sh[[ow]] nat
cisco_asa_ping.textfsm, .*, cisco_(asa|ftd), ping
cisco_asa_dir.textfsm, .*, cisco_asa, dir

cisco_ftd_show_vpn-sessiondb_anyconnect.textfsm, .*, cisco_ftd, sh[[ow]] vpn-[[sessiondb]] a[[nyconnect]]

cisco_ios_show_module.textfsm:cisco_ios_show_module_status.textfsm:cisco_ios_show_module_submodule.textfsm:cisco_ios_show_module_online_diag.textfsm, .*, cisco_ios, sh[[ow]] mod[[ule]]
cisco_ios_show_switch_detail.textfsm:cisco_ios_show_switch_detail_stack_ports.textfsm, .*, cisco_ios, sh[[ow]] sw[[itch]] d[[etail]]
cisco_ios_show_running-config_partition_access-list.textfsm, .*, cisco_ios, sh[[ow]] ru[[nning-config]] p[[artition]] a[[ccess-list]]
Expand Down Expand Up @@ -244,6 +246,7 @@ cisco_ios_show_ip_source_binding.textfsm, .*, cisco_ios, sh[[ow]] ip sou[[rce]]
cisco_ios_show_ip_vrf_interfaces.textfsm, .*, cisco_ios, sh[[ow]] ip vr[[f]] in[[terfaces]]
cisco_ios_show_ipv6_access-lists.textfsm, .*, cisco_ios, sh[[ow]] ipv6 acce[[ss-lists]]
cisco_ios_show_mac-address-table.textfsm, .*, cisco_ios, sh[[ow]] mac[[-address-table]]
cisco_ios_show_ap_cdp_neighbors.textfsm, .*, cisco_ios, sh[[ow]] ap c[[dp]] n[[eighbors]]
cisco_ios_show_ip_bgp_neighbors.textfsm, .*, cisco_ios, sh[[ow]] ip bgp nei[[ghbors]]
cisco_ios_show_ip_ospf_database.textfsm, .*, cisco_ios, sh[[ow]] ip ospf data[[base]]
cisco_ios_show_ip_ospf_neighbor.textfsm, .*, cisco_ios, sh[[ow]] ip ospf nei[[ghbor]]
Expand Down Expand Up @@ -317,8 +320,8 @@ cisco_ios_show_vrf.textfsm, .*, cisco_ios, sh[[ow]] vrf
cisco_ios_ping.textfsm, .*, cisco_ios, ping
cisco_ios_dir.textfsm, .*, cisco_ios, dir

cisco_nxos_show_bgp_vrf_all_ipv4_unicast_neighbors_routes.textfsm, .*, cisco_nxos, sh[[ow]] bg[[p]] v[[rf]] (\S+) ipv4 uni[[cast]] neigh[[bors]] (ro[[utes]]|re[[ceived-routes]]|a[[dvertised-routes]])
cisco_nxos_show_l2rib_internal_permanently-frozen-list.textfsm, .*, cisco_nxos, sh[[ow]] l2ri[[b]] i[[nternal]] pe[[rmanently-frozen-list]]
cisco_nxos_show_bgp_vrf_all_ipv4_unicast_neighbors.textfsm, .*, cisco_nxos, sh[[ow]] bg[[p]] v[[rf]] all ip[[v4]] uni[[cast]] neigh[[bors]]
cisco_nxos_show_ip_pim_interface_brief_vrf_all.textfsm, .*, cisco_nxos, sh[[ow]] ip pim int[[erface]] br[[ief]] vrf all
cisco_nxos_show_configuration_session_summary.textfsm, .*, cisco_nxos, sh[[ow]] configu[[ration]] s[[ession]] su[[mmary]]
cisco_nxos_show_interface_transceiver_details.textfsm, .*, cisco_nxos, sh[[ow]] int[[erface]] tra[[nsceiver]] de[[tails]]
Expand Down
9 changes: 9 additions & 0 deletions tests/arista_eos/show_ip_bgp/arista_eos_show_ip_bgp.raw
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,12 @@ AS Path Attributes: Or-ID - Originator ID, C-LST - Cluster List, LL Nexthop - Li
* # 10.104.2.0/24 10.10.10.20 0 100 0 104 i
* # 10.104.3.0/24 10.10.10.20 0 100 0 104 i
* # 10.104.4.0/24 10.10.10.20 0 100 0 104 i
BGP routing table information for VRF INTERNET
Router identifier 172.26.159.40, local AS number 62222.4003
Route status codes: s - suppressed, * - valid, > - active, # - not installed, E - ECMP head, e - ECMP
S - Stale, c - Contributing to ECMP, b - backup, L - labeled-unicast
Origin codes: i - IGP, e - EGP, ? - incomplete
AS Path Attributes: Or-ID - Originator ID, C-LST - Cluster List, LL Nexthop - Link Local Nexthop

Network Next Hop Metric LocPref Weight Path
* > 10.9.41.96/29 172.26.159.6 0 5000 0 62222.4002 ?
37 changes: 37 additions & 0 deletions tests/arista_eos/show_ip_bgp/arista_eos_show_ip_bgp.yml
Original file line number Diff line number Diff line change
@@ -1,82 +1,119 @@
---
parsed_sample:
- as_path: ""
local_as: "103"
local_pref: "0"
metric: "1"
network: "10.103.1.0/24"
next_hop: "-"
origin: "i"
path_selection: " "
router_id: "10.103.1.1"
route_source: ">"
status: "*"
vrf: "default"
weight: "-"
- as_path: ""
local_as: "103"
local_pref: "0"
metric: "1"
network: "10.103.2.0/24"
next_hop: "-"
origin: "i"
path_selection: " "
router_id: "10.103.1.1"
route_source: ">"
status: "*"
vrf: "default"
weight: "-"
- as_path: ""
local_as: "103"
local_pref: "0"
metric: "1"
network: "10.103.3.0/24"
next_hop: "-"
origin: "i"
path_selection: " "
router_id: "10.103.1.1"
route_source: ">"
status: "*"
vrf: "default"
weight: "-"
- as_path: ""
local_as: "103"
local_pref: "0"
metric: "1"
network: "10.103.4.0/24"
next_hop: "-"
origin: "i"
path_selection: " "
router_id: "10.103.1.1"
route_source: ">"
status: "*"
vrf: "default"
weight: "-"
- as_path: "104"
local_as: "103"
local_pref: "100"
metric: "0"
network: "10.104.1.0/24"
next_hop: "10.10.10.20"
origin: "i"
path_selection: " "
router_id: "10.103.1.1"
route_source: "#"
status: "*"
vrf: "default"
weight: "0"
- as_path: "104"
local_as: "103"
local_pref: "100"
metric: "0"
network: "10.104.2.0/24"
next_hop: "10.10.10.20"
origin: "i"
path_selection: " "
router_id: "10.103.1.1"
route_source: "#"
status: "*"
vrf: "default"
weight: "0"
- as_path: "104"
local_as: "103"
local_pref: "100"
metric: "0"
network: "10.104.3.0/24"
next_hop: "10.10.10.20"
origin: "i"
path_selection: " "
router_id: "10.103.1.1"
route_source: "#"
status: "*"
vrf: "default"
weight: "0"
- as_path: "104"
local_as: "103"
local_pref: "100"
metric: "0"
network: "10.104.4.0/24"
next_hop: "10.10.10.20"
origin: "i"
path_selection: " "
router_id: "10.103.1.1"
route_source: "#"
status: "*"
vrf: "default"
weight: "0"
- as_path: "62222.4002"
local_as: "62222.4003"
local_pref: "5000"
metric: "0"
network: "10.9.41.96/29"
next_hop: "172.26.159.6"
origin: "?"
path_selection: " "
router_id: "172.26.159.40"
route_source: ">"
status: "*"
vrf: "INTERNET"
weight: "0"
2 changes: 1 addition & 1 deletion tests/arista_eos/show_ip_bgp/arista_eos_show_ip_bgp2.raw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GP routing table information for VRF default
BGP routing table information for VRF default
Router identifier 200.200.202.4, local AS number 64805
Route status codes: s - suppressed, * - valid, > - active, E - ECMP head, e - ECMP
S - Stale, c - Contributing to ECMP
Expand Down
Loading

0 comments on commit 8a1a898

Please sign in to comment.