Skip to content

Commit

Permalink
Fix template for ipv6
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcgill298 committed Dec 22, 2022
1 parent 655386e commit acca5dd
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 19 deletions.
30 changes: 15 additions & 15 deletions ntc_templates/templates/linux_ip_address_show.textfsm
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ Value Required GROUP (\S+)
Value QLEN (\d+)
Value MASTER (\S+)
Value Required TYPE (\S+)
Value ADDRESS ([a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2})
Value BROADCAST ([a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2})
Value List IP_ADDRESSES ([0-9A-Fa-f:\.]+)
Value List IP_MASKS (\d{1,3})
Value ADDRESS ((?:[a-fA-F0-9:]{17}))
Value BROADCAST ((?:[a-fA-F0-9:]{17}))
Value List IP_ADDRESSES ([0-9\.]+)
Value List IP_MASKS (\d{1,2})
Value List IPV6_ADDRESSES ([0-9A-Fa-f:]+)
Value List IPV6_MASKS (\d{1,3})

Start
^\d+ -> Continue.Record
^${ID}: ${INTERFACE}: <${FLAGS}> mtu ${MTU} qdisc ${QDISC} state ${STATE} group ${GROUP} qlen ${QLEN}$$ -> Continue
^${ID}: ${INTERFACE}: <${FLAGS}> mtu ${MTU} qdisc ${QDISC} master ${MASTER} state ${STATE} group ${GROUP} qlen ${QLEN}$$ -> Continue
^${ID}: ${INTERFACE}: <${FLAGS}> mtu ${MTU} qdisc ${QDISC} state ${STATE} group ${GROUP} -> Continue
^${ID}: ${INTERFACE}: <${FLAGS}> mtu ${MTU} qdisc ${QDISC} state ${STATE} group ${GROUP} qlen ${QLEN}$$ -> Continue
# Link type, MAC address, IP -> Continue
^\s+link/${TYPE}$$ -> Continue
^\s+link/${TYPE} ${ADDRESS} brd ${BROADCAST}$$ -> Continue
^\s+inet6* ${IP_ADDRESSES}/${IP_MASKS} brd.*$$ -> Continue
^\s+inet6* ${IP_ADDRESSES}/${IP_MASKS} scope.*$$ -> Continue
^\d+: -> Continue.Record
^${ID}:\s+${INTERFACE}:\s+<${FLAGS}>\s+mtu\s+${MTU}\s+qdisc\s+${QDISC}(?:\s+master\s+${MASTER})?\s+state\s+${STATE}\s+group\s+${GROUP}(?:\s+qlen\s+${QLEN})?\s*$$
^\s+link/(?:${TYPE}\s+${ADDRESS}\s+brd\s+${BROADCAST}|none).*$$
^altname.*$$
^\s+inet\s+${IP_ADDRESSES}/${IP_MASKS}\s+brd.*$$
^\s+inet\s+${IP_ADDRESSES}/${IP_MASKS}\s+scope.*$$
^\s+inet6\s+${IPV6_ADDRESSES}/${IP_MASKS}\s+brd.*$$
^\s+inet6\s+${IPV6_ADDRESSES}/${IP_MASKS}\s+scope.*$$
^\s+valid_lft.*$$
^\s*$$
^-> Error
#^. -> Error
12 changes: 12 additions & 0 deletions tests/linux/ip_address_show/linux_ip_address_show.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ parsed_sample:
- "127.0.0.1"
ip_masks:
- "8"
ipv6_addresses: []
ipv6_masks: []
- id: "2"
interface: "ens32"
flags: "BROADCAST,MULTICAST,UP,LOWER_UP"
Expand All @@ -32,6 +34,8 @@ parsed_sample:
- "192.168.131.128"
ip_masks:
- "24"
ipv6_addresses: []
ipv6_masks: []
- id: "3"
interface: "gpd0"
flags: "POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP"
Expand All @@ -48,6 +52,8 @@ parsed_sample:
- "10.20.20.12"
ip_masks:
- "32"
ipv6_addresses: []
ipv6_masks: []
- id: "4"
interface: "br-218f5e637867"
flags: "NO-CARRIER,BROADCAST,MULTICAST,UP"
Expand All @@ -64,6 +70,8 @@ parsed_sample:
- "172.21.0.1"
ip_masks:
- "16"
ipv6_addresses: []
ipv6_masks: []
- id: "5"
interface: "vrf-blue"
flags: "NOARP,MASTER,UP,LOWER_UP"
Expand All @@ -78,6 +86,8 @@ parsed_sample:
broadcast: "ff:ff:ff:ff:ff:ff"
ip_addresses: []
ip_masks: []
ipv6_addresses: []
ipv6_masks: []
- id: "6"
interface: "brblue"
flags: "BROADCAST,MULTICAST,UP,LOWER_UP"
Expand All @@ -96,3 +106,5 @@ parsed_sample:
ip_masks:
- "24"
- "25"
ipv6_addresses: []
ipv6_masks: []
18 changes: 14 additions & 4 deletions tests/linux/ip_address_show/linux_ip_address_show2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ parsed_sample:
- "127.0.0.1"
ip_masks:
- "8"
ipv6_addresses: []
ipv6_masks: []
- id: "2"
interface: "eth0"
flags: "BROADCAST,MULTICAST,UP,LOWER_UP"
Expand All @@ -30,9 +32,11 @@ parsed_sample:
broadcast: "ff:ff:ff:ff:ff:ff"
ip_addresses:
- "192.168.121.45"
- "fe80::5054:ff:fe8c:6244"
ip_masks:
- "24"
ipv6_addresses:
- "fe80::5054:ff:fe8c:6244"
ipv6_masks:
- "64"
- id: "3"
interface: "ens33"
Expand All @@ -48,9 +52,11 @@ parsed_sample:
broadcast: "ff:ff:ff:ff:ff:ff"
ip_addresses:
- "192.168.94.133"
- "fe80::b681:60db:7206:13a0"
ip_masks:
- "24"
ipv6_addresses:
- "fe80::b681:60db:7206:13a0"
ipv6_masks:
- "64"
- id: "4"
interface: "ens37"
Expand All @@ -66,9 +72,11 @@ parsed_sample:
broadcast: "ff:ff:ff:ff:ff:ff"
ip_addresses:
- "192.168.94.134"
- "fe80::6c2a:3447:5d99:700a"
ip_masks:
- "24"
ipv6_addresses:
- "fe80::6c2a:3447:5d99:700a"
ipv6_masks:
- "64"
- id: "5"
interface: "ens38"
Expand All @@ -84,7 +92,9 @@ parsed_sample:
broadcast: "ff:ff:ff:ff:ff:ff"
ip_addresses:
- "192.168.94.135"
- "fe80::97ef:a3f1:a962:9ef0"
ip_masks:
- "24"
ipv6_addresses:
- "fe80::97ef:a3f1:a962:9ef0"
ipv6_masks:
- "64"

0 comments on commit acca5dd

Please sign in to comment.