Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize capture group to PREFIX_LENGTH #1432

Merged
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Value IN_OUT_USE (\*>i|u\*>i|\*i)
Value RD (\d+\:\d+)
Value Required PREFIX (\d+\.\d+\.\d+\.\d+\/[1-9][0-9]?)
Value Required NETWORK (\d+(\.\d+){3})
Value Required PREFIX_LENGTH (\d{1,2})
Value LOCAL_PREF (\d+)
Value MED (None|d\+)
Value NEXT_HOP (\d+\.\d+\.\d+\.\d+)
Expand All @@ -12,6 +13,6 @@ Start
^----------- -> Prefix

Prefix
^${IN_OUT_USE}\s+${RD}\:${PREFIX}\s+${LOCAL_PREF}\s+${MED}
^${IN_OUT_USE}\s+${RD}\:${NETWORK}\/${PREFIX_LENGTH}\s+${LOCAL_PREF}\s+${MED}
^\s+${NEXT_HOP}\s+${PATH_ID}\s+${LABEL}
^\s+${AS_PATH} -> Record
6 changes: 3 additions & 3 deletions ntc_templates/templates/arista_eos_show_ip_route.textfsm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Value Filldown VRF (\S+)
Value PROTOCOL (\S+\s\S+?|\w?)
Value Required NETWORK (\d+\.\d+\.\d+\.\d+)
Value MASK (\d+)
Value PREFIX_LENGTH (\d+)
Value DISTANCE (\d+)
Value METRIC (\d+)
Value DIRECT (directly)
Expand All @@ -24,8 +24,8 @@ Start

Routes
^\s+(\S+\s\S+?|\w?)\s+(\d+\.\d+\.\d+\.\d+)/(\d+)\s -> Continue.Record
^\s+${PROTOCOL}\s+${NETWORK}/${MASK}\s+is\s+${DIRECT}\s+${NEXT_HOP},\s+${INTERFACE}$$
^\s+${PROTOCOL}\s+${NETWORK}/${MASK}\s+(?:\[${DISTANCE}/${METRIC}\]|is\s+${DIRECT})(?:.+?)${NEXT_HOP},\s+${INTERFACE}$$
^\s+${PROTOCOL}\s+${NETWORK}/${PREFIX_LENGTH}\s+is\s+${DIRECT}\s+${NEXT_HOP},\s+${INTERFACE}$$
^\s+${PROTOCOL}\s+${NETWORK}/${PREFIX_LENGTH}\s+(?:\[${DISTANCE}/${METRIC}\]|is\s+${DIRECT})(?:.+?)${NEXT_HOP},\s+${INTERFACE}$$
^\s+via\s+${NEXT_HOP},\s+${INTERFACE}
^\s*$$ -> Record
^VRF(\s+name)?:\s+${VRF}\s*$$ -> Start
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Value INTERFACE (\S+\s\S+)
Value IPADDR (\S+)
Value MASK (\S+)
Value NETMASK (\S+)
Value ADMIN (\S+)
Value PROTOCOL (\S+)

Start
^${INTERFACE}\s+${IPADDR}\s+/\s+${MASK}\s+${ADMIN}\s+${PROTOCOL} -> Record
^${INTERFACE}\s+${IPADDR}\s+/\s+${NETMASK}\s+${ADMIN}\s+${PROTOCOL} -> Record
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Value PROTOCOL (C|S|R|B|O|A|K|H|P|U|i)
Value NETWORK ([0-9a-f:]*)
Value MASK (\d{1,3})
Value PREFIX_LENGTH (\d{1,3})
Value NEXTHOPIP ([0-9a-f:]*)
Value INTERFACE (\S+)
Value COMMENT (\S.*)
Expand All @@ -9,8 +9,8 @@ Value COMMENT (\S.*)
Start
^\S\s -> Continue.Record
# Match regular routes
^${PROTOCOL}\s+${NETWORK}/${MASK}\s+via\s${NEXTHOPIP},\s${INTERFACE},
^${PROTOCOL}\s+${NETWORK}/${PREFIX_LENGTH}\s+via\s${NEXTHOPIP},\s${INTERFACE},
# Match directly connected routes
^${PROTOCOL}\s+${NETWORK}/${MASK}\s+is directly connected,\s${INTERFACE}
^${PROTOCOL}\s+${NETWORK}/${PREFIX_LENGTH}\s+is directly connected,\s${INTERFACE}
# Match optional comment, ignore trailing whitespace
^\s{39}${COMMENT}\s*$$
4 changes: 2 additions & 2 deletions ntc_templates/templates/cisco_asa_show_interface.textfsm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Value ADDRESS ([a-zA-Z0-9]+.[a-zA-Z0-9]+.[a-zA-Z0-9]+)
Value MTU (\d+)
Value VLAN_ID (\d+)
Value IP_ADDRESS (\d+\.\d+\.\d+\.\d+)
Value NET_MASK (\d+\.\d+\.\d+\.\d+)
Value NETMASK (\d+\.\d+\.\d+\.\d+)
Value ONEMIN_IN_PPS (\d+)
Value ONEMIN_IN_RATE (\d+)
Value ONEMIN_OUT_PPS (\d+)
Expand Down Expand Up @@ -48,7 +48,7 @@ Start
^.*MAC\s+address\s+${ADDRESS},\s+MTU\s+not\s+set
^\s+Available\s+but\s+not\s+configured\s+via\s+nameif
^.*MAC\s+address\s+N/A,\s+MTU\s+${MTU}
^.*IP\s+address\s+${IP_ADDRESS},\s+subnet\s+mask\s+${NET_MASK}
^.*IP\s+address\s+${IP_ADDRESS},\s+subnet\s+mask\s+${NETMASK}
^.*1\s+minute\s+input\s+rate\s+${ONEMIN_IN_PPS}\s+pkts/sec,\s+${ONEMIN_IN_RATE}\s+bytes/sec
^.*1\s+minute\s+output\s+rate\s+${ONEMIN_OUT_PPS}\s+pkts/sec,\s+${ONEMIN_OUT_RATE}\s+bytes/sec
^.*1\s+minute\s+drop\s+rate,\s+${ONEMIN_DROP_RATE}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Value DESCRIPTION (.*)
Value ADDRESS ([a-zA-Z0-9]+\.[a-zA-Z0-9]+\.[a-zA-Z0-9]+)
Value MTU (.+?)
Value IP_ADDRESS (.+?)
Value NET_MASK (.+?)
Value NETMASK (.+?)
Value IN_PACKETS (\d+)
Value IN_BYTES (\d+)
Value NO_BUFFER (\d+)
Expand Down Expand Up @@ -86,7 +86,7 @@ Start
^\s+Active\s+member\s+of\s+${BONDED_PORT}\s*$$
^\s+Description:\s+${DESCRIPTION}
^\s+MAC\s+address\s+${ADDRESS}.*MTU\s+${MTU}\s*$$
^\s+IP\s+[Aa]ddress\s+${IP_ADDRESS}(?:,\s+[Ss]ubnet\s+[Mm]ask\s+${NET_MASK})?\s*$$
^\s+IP\s+[Aa]ddress\s+${IP_ADDRESS}(?:,\s+[Ss]ubnet\s+[Mm]ask\s+${NETMASK})?\s*$$
^\s+${IN_PACKETS}\s+packets\s+input,\s+${IN_BYTES}\s+bytes,\s+${NO_BUFFER}\s+no\s+buffer
^\s+Received\s+${BROADCASTS}\s+broadcasts,\s+${RUNTS}\s+runts,\s+${GIANTS}\s+giants
^\s+${IN_ERRORS}\s+input\s+errors,\s+${CRC}\s+CRC,\s+${FRAME}\s+frame,\s+${OVERRUN}\s+overrun,\s+${IGNORED}\s+ignored,\s+${ABORT}\s+abort
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Value TYPE ([newrkguphsobjct]+)
Value HOST (\d+.\d+.\d+.\d+)
Value NET_OBJECT (\S+)
Value NETWORK (\d+.\d+.\d+.\d+)
Value MASK (\d+.\d+.\d+.\d+)
Value NETMASK (\d+.\d+.\d+.\d+)
Value GRP_OBJECT (\S+)

Start
Expand All @@ -13,7 +13,7 @@ Start
^\s+description:?\s+${DESCRIPTION}\s*
^\s+network-object\s+${TYPE}\s+${HOST}\s* -> Record
^\s+network-object\s+${TYPE}\s+${NET_OBJECT}\s* -> Record
^\s+${TYPE}-object\s+${NETWORK}\s+${MASK}\s* -> Record
^\s+${TYPE}-object\s+${NETWORK}\s+${NETMASK}\s* -> Record
^\s+${TYPE}-object\s+${GRP_OBJECT}\s* -> Record

EOF
12 changes: 6 additions & 6 deletions ntc_templates/templates/cisco_asa_show_route.textfsm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Value Filldown PROTOCOL (C|S|R|B|D|O|i|L)
Value Filldown TYPE (\w{0,2})
Value Required,Filldown NETWORK (\d+\.\d+\.\d+\.\d+|\S+)
Value Filldown MASK (\d+\.\d+\.\d+\.\d+)
Value Filldown NETMASK (\d+\.\d+\.\d+\.\d+)
Value DISTANCE (\d+)
Value METRIC (\d+)
Value NEXTHOPIP (\d+\.\d+\.\d+\.\d+)
Expand All @@ -13,26 +13,26 @@ Start

ROUTES
# Match regular routes with all data in same line
^${PROTOCOL}(\s|\*)${TYPE}\s+${NETWORK}\s+${MASK}\s\[${DISTANCE}\/${METRIC}\]\svia\s${NEXTHOPIP}(,\s${UPTIME}){0,1}(,\s${NEXTHOPIF}){0,1}\s*$$ -> Record
^${PROTOCOL}(\s|\*)${TYPE}\s+${NETWORK}\s+${NETMASK}\s\[${DISTANCE}\/${METRIC}\]\svia\s${NEXTHOPIP}(,\s${UPTIME}){0,1}(,\s${NEXTHOPIF}){0,1}\s*$$ -> Record
#
# Clear all non Filldown variables when line started with network that is variably subnetted
^\s+[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}${MASK}\s*$$ -> Clear
^\s+[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}${NETMASK}\s*$$ -> Clear
^${PROTOCOL}(\s|\*)${TYPE}\s+${NETWORK}\s\[${DISTANCE}\/${METRIC}\]\svia\s${NEXTHOPIP}(,\s${UPTIME}){0,1}(,\s${NEXTHOPIF}){0,1}\s*$$ -> Record
#
# Match multiline route statements
^${PROTOCOL}(\s|\*)${TYPE}\s+${NETWORK}\s+${MASK}\s*$$
^${PROTOCOL}(\s|\*)${TYPE}\s+${NETWORK}\s+${NETMASK}\s*$$
#
# Match load-balanced routes
^\s+\[${DISTANCE}\/${METRIC}\]\s+via\s+${NEXTHOPIP},(?:\s+${UPTIME},)?\s+${NEXTHOPIF}\s*$$ -> Record
#
# Match directly connected routes
^${PROTOCOL}\s${TYPE}\s+${NETWORK}\sis\sdirectly\sconnected,\s${NEXTHOPIF} -> Record
^${PROTOCOL}(\*){0,1}\s${TYPE}\s+${NETWORK}\s+${MASK}\sis\sdirectly\sconnected,\s${NEXTHOPIF} -> Record
^${PROTOCOL}(\*){0,1}\s${TYPE}\s+${NETWORK}\s+${NETMASK}\sis\sdirectly\sconnected,\s${NEXTHOPIF} -> Record
#
# Clear all variables on empty lines
^\s* -> Clearall
#^${TYPE} -> Continue.Record
#^${TYPE}\s+${NETWORK}\s+${MASK}\s+\[\d+\/\d+\]\s+via\s+${GATEWAY}\,\s+${UPTIME},\s+${INTFC}\s*$$ -> Record
#^${TYPE}\s+${NETWORK}\s+${NETMASK}\s+\[\d+\/\d+\]\s+via\s+${GATEWAY}\,\s+${UPTIME},\s+${INTFC}\s*$$ -> Record
#^\s+\[\d+\/\d+\]\s+via\s+${GATEWAY}\,\s+${UPTIME},\s+${INTFC}\s*$$ -> Record

EOF
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Value DESCRIPTION (.+)
Value TYPE ([hostubnerag]+)
Value HOST (\S+)
Value NETWORK (\S+)
Value MASK (\S+)
Value CIDR (\/\d+)
Value NETMASK (\S+)
Value PREFIX_LENGTH (\d+)
Value START_IP (\S+)
Value END_IP (\S+)

Expand All @@ -14,8 +14,8 @@ Start
^object\s+network\s+${NAME}\s*
^\s+description\s+${DESCRIPTION}\s*
^\s+${TYPE} -> Continue
^\s+subnet\s+${NETWORK}\s+${MASK}\s*
^\s+subnet\s+${NETWORK}${CIDR}\s*
^\s+subnet\s+${NETWORK}\s+${NETMASK}\s*
^\s+subnet\s+${NETWORK}\/${PREFIX_LENGTH}\s*
^\s+range\s+${START_IP}\s+${END_IP}\s*
^\s+host\s+${HOST}\s*
^. -> Error
9 changes: 5 additions & 4 deletions ntc_templates/templates/cisco_ios_show_ip_cef.textfsm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
# This is enforced by INDEX file
# Check cisco_ios_show_ip_cef_detail.textfsm for more details
#
Value Required PREFIX ((?:\d{1,3}\.){3}\d{1,3}\/\d{1,2})
Value Required IP_ADDRESS ((?:\d{1,3}\.){3}\d{1,3})
Value Required PREFIX_LENGTH (\d{1,2})
# To support ECMP, NEXTHOP and INTERFACE are defined as lists
# When no ECMP is available, these will be single item lists
# However, if there are multiple paths available
Expand All @@ -31,12 +32,12 @@ Entries
# Entry detected
^(?:\d{1,3}\.){3}\d{1,3}\/\d{1,2} -> Continue.Record
# Parse prefix/nexthop
^${PREFIX}\s+${NEXTHOP}\s*$$
^${IP_ADDRESS}\/${PREFIX_LENGTH}\s+${NEXTHOP}\s*$$
# Parse prefix, nexthop and interface
^${PREFIX}\s+${NEXTHOP}\s+${INTERFACE}$$
^${IP_ADDRESS}\/${PREFIX_LENGTH}\s+${NEXTHOP}\s+${INTERFACE}$$
# Parse nexthop and interface for ECMP prefixes
^\s+${NEXTHOP}\s+${INTERFACE}$$
#
# >>> Parse SPECIAL
^\s*$$
^. -> Error
^. -> Error
9 changes: 5 additions & 4 deletions ntc_templates/templates/cisco_ios_show_ip_cef_detail.textfsm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
# Template is able to recognize both versions and captures
# same structured data regardless of IOS version.
#
Value Required PREFIX ((?:\d{1,3}\.){3}\d{1,3}\/\d{1,2})
Value Required IP_ADDRESS ((?:\d{1,3}\.){3}\d{1,3})
Value Required PREFIX_LENGTH (\d{1,2})
# Nexthop and Interface are lists to support ECMP
# Usually these will be single item lists
# However, if there are multiple paths available
Expand Down Expand Up @@ -40,7 +41,7 @@ Start
#
# >>>>>> Cisco IOS >v15.x
# Extract prefix (no flags)
^${PREFIX},\s+epoch
^${IP_ADDRESS}\/${PREFIX_LENGTH},\s+epoch
# Extract nexthop for recursive entries
^\s+recursive\s+via\s+${NEXTHOP} -> Recursive
# Extract nexthop (receive) and interface
Expand All @@ -60,7 +61,7 @@ Start
#
# >>>>>> Cisco IOS 12.x ISR G1 (legacy CEF formatting)
# Extract prefix
^${PREFIX},\s+version -> Continue
^${IP_ADDRESS}\/${PREFIX_LENGTH},\s+version -> Continue
# Extract nexthop (receive and attached)
^.*?epoch\s+\d+,.+?${NEXTHOP}(?<=receive)
^.*?epoch\s+\d+,.+?${NEXTHOP}(?<=attached)
Expand Down Expand Up @@ -101,4 +102,4 @@ Recursive
# Extract interface for recursive entries
^\s+attached\s+to\s+${INTERFACE} -> Start
^\s*$$
^. -> Error
^. -> Error
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Value Filldown PROCESS_ID (\d+)
Value Filldown ROUTER_ID (\d+\.\d+\.\d+\.\d+)
Value Required CODE (\S+)
Value ROUTE (\d+\.\d+\.\d+\.\d+)
Value MASK (\d+)
Value PREFIX_LENGTH (\d+)
Value SUCCESSORS (\d+)
Value FD (\d+|Inaccessible)
Value TAG (\d+)
Expand All @@ -20,9 +20,9 @@ Start
# Skips over the definitions for the codes
^\s*\S\s-\s\S+
# Matches a route and captures if ${TAG} is use for the route and then moves to Gateway section
^${CODE}\s+${ROUTE}/${MASK},\s+${SUCCESSORS}\s+successors,\s+FD\s+is\s+${FD},\s+tag\s+is\s+${TAG} -> Gateway
^${CODE}\s+${ROUTE}/${PREFIX_LENGTH},\s+${SUCCESSORS}\s+successors,\s+FD\s+is\s+${FD},\s+tag\s+is\s+${TAG} -> Gateway
# Matches a route and captures it and then moves to Gateway section
^${CODE}\s+${ROUTE}/${MASK},\s+${SUCCESSORS}\s+successors,\s+FD\s+is\s+${FD} -> Gateway
^${CODE}\s+${ROUTE}/${PREFIX_LENGTH},\s+${SUCCESSORS}\s+successors,\s+FD\s+is\s+${FD} -> Gateway
# If it doesn't match anything above, this just acknowledges a new line
^\s*$$
# This will throw an error if there are no matches
Expand All @@ -38,8 +38,8 @@ Gateway
# This will not capture anything but if it encounters another route, it will continue and record what it already captured
^\S+\s+(?:\d+(?:\.|)){4}/\d+,\s+\d+\s+successors -> Continue.Record
# These are the same as above and capture the next set of routes
^${CODE}\s+${ROUTE}/${MASK},\s+${SUCCESSORS}\s+successors,\s+FD\s+is\s+${FD},\s+tag\s+is\s+${TAG}
^${CODE}\s+${ROUTE}/${MASK},\s+${SUCCESSORS}\s+successors,\s+FD\s+is\s+${FD}
^${CODE}\s+${ROUTE}/${PREFIX_LENGTH},\s+${SUCCESSORS}\s+successors,\s+FD\s+is\s+${FD},\s+tag\s+is\s+${TAG}
^${CODE}\s+${ROUTE}/${PREFIX_LENGTH},\s+${SUCCESSORS}\s+successors,\s+FD\s+is\s+${FD}
# If it encounters another AS/Router ID it will continue and record what it just captured
^.+AS\(\d+\)/ID -> Continue.Record
# If it encounters it again, it will continue, but clear all captured data other than Filldown Values
Expand Down
6 changes: 3 additions & 3 deletions ntc_templates/templates/cisco_ios_show_ip_interface.textfsm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Value Required INTERFACE (\S+)
Value LINK_STATUS (.+?)
Value PROTOCOL_STATUS (.+?)
Value List IPADDR (\S+?)
Value List MASK (\d*)
Value List PREFIX_LENGTH (\d*)
Value VRF (\S+)
Value MTU (\d+)
Value List IP_HELPER (\d+\.\d+\.\d+\.\d+)
Expand All @@ -13,9 +13,9 @@ Value INBOUND_ACL (.*?)
Start
^\S -> Continue.Record
^${INTERFACE}\s+is\s+${LINK_STATUS},\s+line\s+protocol\s+is\s+${PROTOCOL_STATUS}\s*$$
^\s+Internet\s+address\s+is\s+${IPADDR}/?${MASK}\s*$$
^\s+Internet\s+address\s+is\s+${IPADDR}/?${PREFIX_LENGTH}\s*$$
^\s+Internet\s+address\s+will\s+be\s+negotiated
^\s+Secondary\s+address\s+${IPADDR}/?${MASK}\s*$$
^\s+Secondary\s+address\s+${IPADDR}/?${PREFIX_LENGTH}\s*$$
^.+VPN\s+Routing/Forwarding\s+"${VRF}"
^\s+MTU\s+is\s+${MTU}\s+bytes
^\s+Helper\s+address(es|)\s(is|are)\s+${IP_HELPER}\s*$$ -> HELPERS
Expand Down
14 changes: 7 additions & 7 deletions ntc_templates/templates/cisco_ios_show_ip_route.textfsm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Value Filldown VRF (\S+)
Value Filldown PROTOCOL (\w)
Value Filldown TYPE (\w{0,2})
Value Required,Filldown NETWORK (\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})
Value Filldown MASK (\d{1,2})
Value Filldown PREFIX_LENGTH (\d{1,2})
Value DISTANCE (\d+)
Value METRIC (\d+)
Value NEXTHOP_IP (\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})
Expand All @@ -20,28 +20,28 @@ Start
Routes
^\s*$$
# For "is (variably )subnetted" line, capture mask, clear all values.
^\s+\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\/${MASK}\sis -> Clear
^\s+\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\/${PREFIX_LENGTH}\sis -> Clear
#
# Match directly connected route with explicit mask
^${PROTOCOL}(\s|\*)${TYPE}\s+${NETWORK}\/${MASK}\sis\sdirectly\sconnected(,\s${UPTIME})?(,\s${NEXTHOP_IF})? -> Record
^${PROTOCOL}(\s|\*)${TYPE}\s+${NETWORK}\/${PREFIX_LENGTH}\sis\sdirectly\sconnected(,\s${UPTIME})?(,\s${NEXTHOP_IF})? -> Record
#
# Match directly connected route (mask is inherited from "is subnetted")
^${PROTOCOL}(\s|\*)${TYPE}\s+${NETWORK}\sis\sdirectly\sconnected,\s${NEXTHOP_IF} -> Record
#
# Match regular routes, with mask, where all data in same line
^${PROTOCOL}(\s|\*)${TYPE}\s+${NETWORK}\/${MASK}\s\[${DISTANCE}/${METRIC}\]\svia\s${NEXTHOP_IP}(\s\(${NEXTHOP_VRF}\))?(,\s${UPTIME})?(,\s${NEXTHOP_IF})? -> Record
^${PROTOCOL}(\s|\*)${TYPE}\s+${NETWORK}\/${PREFIX_LENGTH}\s\[${DISTANCE}/${METRIC}\]\svia\s${NEXTHOP_IP}(\s\(${NEXTHOP_VRF}\))?(,\s${UPTIME})?(,\s${NEXTHOP_IF})? -> Record
#
# Match regular route, all one line, where mask is learned from "is subnetted" line
^${PROTOCOL}(\s|\*)${TYPE}\s+${NETWORK}\s\[${DISTANCE}\/${METRIC}\]\svia\s${NEXTHOP_IP}(,\s${UPTIME})?(,\s${NEXTHOP_IF})? -> Record
#
# Match route with no via statement (Null via protocol)
^${PROTOCOL}(\s|\*)${TYPE}\s+${NETWORK}\/${MASK}\s\[${DISTANCE}/${METRIC}\],\s${UPTIME},\s${NEXTHOP_IF} -> Record
^${PROTOCOL}(\s|\*)${TYPE}\s+${NETWORK}\/${PREFIX_LENGTH}\s\[${DISTANCE}/${METRIC}\],\s${UPTIME},\s${NEXTHOP_IF} -> Record
#
# Match "is a summary" routes (often Null0)
^${PROTOCOL}(\s|\*)${TYPE}\s+${NETWORK}\/${MASK}\sis\sa\ssummary,\s${UPTIME},\s${NEXTHOP_IF} -> Record
^${PROTOCOL}(\s|\*)${TYPE}\s+${NETWORK}\/${PREFIX_LENGTH}\sis\sa\ssummary,\s${UPTIME},\s${NEXTHOP_IF} -> Record
#
# Match regular routes where the network/mask is on the line above the rest of the route
^${PROTOCOL}(\s|\*)${TYPE}\s+${NETWORK}\/${MASK} -> Next
^${PROTOCOL}(\s|\*)${TYPE}\s+${NETWORK}\/${PREFIX_LENGTH} -> Next
#
# Match regular routes where the network only (mask from subnetted line) is on the line above the rest of the route
^${PROTOCOL}(\s|\*)${TYPE}\s+${NETWORK} -> Next
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Value PREFIX (\d+\.\d+\.\d+\.+\d+\/\d+)
Value Required,List NEXTHOP (Drop|Receive|Attached|\d+\.\d+\.\d+\.\d+)
Value IP_ADDRESS (\d+(\.\d+){3})
Value PREFIX_LENGTH (\d{1,2})
Value Required,List NEXTHOP (Drop|Receive|Attached|\d+(\.\d+){3})
Value List INTERFACE (\S+)

Start
Expand All @@ -11,9 +12,9 @@ FIB
# Start Record on encountering a Prefix, don't substitute any values yet
^\*?(\d+\.\d+\.\d+\.+\d+\/\d+) -> Continue.Record
# Match lines with all Values present, some entries can start with * (for multiple entries in RIB, one in FIB prefixes)
^\*?${PREFIX}\s+${NEXTHOP}\s+${INTERFACE}\s*$$
^\*?${IP_ADDRESS}\/${PREFIX_LENGTH}\s+${NEXTHOP}\s+${INTERFACE}\s*$$
# Match lines which do not have an interface, strange but can exists
^\*?${PREFIX}\s+${NEXTHOP}\s*$$
^\*?${IP_ADDRESS}\/${PREFIX_LENGTH}\s+${NEXTHOP}\s*$$
# Match lines which have Nexthop and interface, and fill in the list; these are for prefixes which have multiple equal cost paths
^\s+${NEXTHOP}\s+${INTERFACE}\s*$$
# Match other lines before erroring out on unknown input lines
Expand Down
4 changes: 2 additions & 2 deletions ntc_templates/templates/cisco_nxos_show_ip_route.textfsm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Value Filldown VRF (\S+)
Value PROTOCOL ([\w-]+)
Value TYPE ([\w-]+)
Value Filldown NETWORK (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})
Value Filldown MASK (\d{1,2})
Value Filldown PREFIX_LENGTH (\d{1,2})
Value DISTANCE (\d+)
Value METRIC (\d+)
Value NEXTHOP_IP (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})
Expand All @@ -17,7 +17,7 @@ Value ENCAP (\w+)
Start
^IP\s+Route\s+Table\s+for\s+VRF\s+"${VRF}"\s*$$
# Match the Network/Prefix Line
^\s*${NETWORK}\/${MASK}, ubest/mbest:
^\s*${NETWORK}\/${PREFIX_LENGTH}, ubest/mbest:
#
# Match empty vrf
^\s*Route not found -> Record
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Value INTERFACE_NAME (\S+)
Value MAC_ADDRESS (\w+\.\w+\.\w+|\w+\:\w+\:\w+\:\w+\:\w+\:\w+)
Value IP_ADDRESS (\d+.\d+.\d+.\d+)
Value IP_NETMASK (\d+.\d+.\d+.\d+)
Value NETMASK (\d+.\d+.\d+.\d+)
Value GATEWAY (\d+.\d+.\d+.\d+)
Value PRIMARY_DHCP_SERVER (\d+.\d+.\d+.\d+|Unconfigured)
Value SECONDARY_DHCP_SERVER (\d+.\d+.\d+.\d+|Unconfigured)
Expand All @@ -10,7 +10,7 @@ Start
^\s*Interface\s+Name\.+\s+${INTERFACE_NAME}\s*$$
^\s*MAC\s+Address\.+\s+${MAC_ADDRESS}\s*$$
^\s*IP\s+Address\.+\s+${IP_ADDRESS}\s*$$
^\s*IP\s+Netmask\.+\s+${IP_NETMASK}\s*$$
^\s*IP\s+Netmask\.+\s+${NETMASK}\s*$$
^\s*IP\s+Gateway\.+\s+${GATEWAY}\s*$$
^\s*Primary\s+DHCP\s+Server\.+\s+${PRIMARY_DHCP_SERVER}\s*$$
^\s*Secondary\s+DHCP\s+Server\.+\s+${SECONDARY_DHCP_SERVER}\s*$$ -> Record
Expand Down
Loading