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

Add new templates #1258

Merged
merged 3 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
29 changes: 13 additions & 16 deletions ntc_templates/templates/linux_ip_address_show.textfsm
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,20 @@ 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 (\d{1,3}.\d{1,3}.\d{1,3}.\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+inet ${IP_ADDRESSES}/${IP_MASKS} brd.*$$ -> Continue
^\s+inet ${IP_ADDRESSES}/${IP_MASKS} scope.*$$ -> Continue
^\s+valid_lft.*$$ -> Continue
^\d+
^\s+
^\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})?.*$$
^\s+altname.*$$
^\s+inet\s+${IP_ADDRESSES}/${IP_MASKS}\s+(:?brd|scope).*$$
^\s+inet6\s+${IPV6_ADDRESSES}/${IPV6_MASKS}\s+(?:brd|scope).*$$
^\s+valid_lft.*$$
^\s*$$
^. -> 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: []
35 changes: 35 additions & 0 deletions tests/linux/ip_address_show/linux_ip_address_show2.raw
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 52:54:00:8c:62:44 brd ff:ff:ff:ff:ff:ff
inet 192.168.121.241/24 brd 192.168.121.255 scope global dynamic eth0
valid_lft 3515sec preferred_lft 3515sec
inet 192.168.121.45/24 scope global secondary eth0
valid_lft forever preferred_lft forever
inet6 fe80::5054:ff:fe8c:6244/64 scope link
valid_lft forever preferred_lft forever
3: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:b0:21:7d brd ff:ff:ff:ff:ff:ff
altname enp2s1
inet 192.168.94.133/24 brd 192.168.94.255 scope global dynamic noprefixroute ens33
valid_lft 1541sec preferred_lft 1541sec
inet6 fe80::b681:60db:7206:13a0/64 scope link noprefixroute
valid_lft forever preferred_lft forever
4: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:50:56:20:47:14 brd ff:ff:ff:ff:ff:ff
altname enp2s5
inet 192.168.94.134/24 brd 192.168.94.255 scope global dynamic noprefixroute ens37
valid_lft 1541sec preferred_lft 1541sec
inet6 fe80::6c2a:3447:5d99:700a/64 scope link noprefixroute
valid_lft forever preferred_lft forever
5: ens38: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:50:56:37:93:58 brd ff:ff:ff:ff:ff:ff
altname enp2s6
inet 192.168.94.135/24 brd 192.168.94.255 scope global dynamic noprefixroute ens38
valid_lft 1540sec preferred_lft 1540sec
inet6 fe80::97ef:a3f1:a962:9ef0/64 scope link noprefixroute
valid_lft forever preferred_lft forever
104 changes: 104 additions & 0 deletions tests/linux/ip_address_show/linux_ip_address_show2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
parsed_sample:
- id: "1"
interface: "lo"
flags: "LOOPBACK,UP,LOWER_UP"
mtu: "65536"
qdisc: "noqueue"
state: "UNKNOWN"
group: "default"
qlen: "1000"
master: ""
type: "loopback"
address: "00:00:00:00:00:00"
broadcast: "00:00:00:00:00:00"
ip_addresses:
- "127.0.0.1"
ip_masks:
- "8"
ipv6_addresses:
- "::1"
ipv6_masks:
- "128"
- id: "2"
interface: "eth0"
flags: "BROADCAST,MULTICAST,UP,LOWER_UP"
mtu: "1500"
qdisc: "fq_codel"
state: "UP"
group: "default"
qlen: "1000"
master: ""
type: "ether"
address: "52:54:00:8c:62:44"
broadcast: "ff:ff:ff:ff:ff:ff"
ip_addresses:
- "192.168.121.241"
- "192.168.121.45"
ip_masks:
- "24"
- "24"
ipv6_addresses:
- "fe80::5054:ff:fe8c:6244"
ipv6_masks:
- "64"
- id: "3"
interface: "ens33"
flags: "BROADCAST,MULTICAST,UP,LOWER_UP"
mtu: "1500"
qdisc: "fq_codel"
state: "UP"
group: "default"
qlen: "1000"
master: ""
type: "ether"
address: "00:0c:29:b0:21:7d"
broadcast: "ff:ff:ff:ff:ff:ff"
ip_addresses:
- "192.168.94.133"
ip_masks:
- "24"
ipv6_addresses:
- "fe80::b681:60db:7206:13a0"
ipv6_masks:
- "64"
- id: "4"
interface: "ens37"
flags: "BROADCAST,MULTICAST,UP,LOWER_UP"
mtu: "1500"
qdisc: "fq_codel"
state: "UP"
group: "default"
qlen: "1000"
master: ""
type: "ether"
address: "00:50:56:20:47:14"
broadcast: "ff:ff:ff:ff:ff:ff"
ip_addresses:
- "192.168.94.134"
ip_masks:
- "24"
ipv6_addresses:
- "fe80::6c2a:3447:5d99:700a"
ipv6_masks:
- "64"
- id: "5"
interface: "ens38"
flags: "BROADCAST,MULTICAST,UP,LOWER_UP"
mtu: "1500"
qdisc: "fq_codel"
state: "UP"
group: "default"
qlen: "1000"
master: ""
type: "ether"
address: "00:50:56:37:93:58"
broadcast: "ff:ff:ff:ff:ff:ff"
ip_addresses:
- "192.168.94.135"
ip_masks:
- "24"
ipv6_addresses:
- "fe80::97ef:a3f1:a962:9ef0"
ipv6_masks:
- "64"