Skip to content

Commit

Permalink
bugfix - handle multiline ipv6 hsrp group output for cisco_xr_show_hs…
Browse files Browse the repository at this point in the history
…rp (#1793)
  • Loading branch information
mjbear authored Jul 29, 2024
1 parent 4b67735 commit 5c26b85
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 9 deletions.
21 changes: 17 additions & 4 deletions ntc_templates/templates/cisco_xr_show_hsrp.textfsm
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
Value INTERFACE (.+?)
Value INTERFACE (\S+)
Value GROUP (\d+)
Value PRIO (\d+)
Value PREEMPT (P)
Value STATE (\w+)
Value ACTIVE_ADDR (\S+)
Value STANDBY_ADDR (\S+)
Value GROUP_ADDR (\S+)
Value GROUP_ADDR ((?:\d+\.?){4}|(?:[a-f0-9]*:){1,7}[a-f0-9]*)

Start
^${INTERFACE}\s+${GROUP}\s+${PRIO}\s+(?:${PREEMPT}\s+)?${STATE}\s+${ACTIVE_ADDR}\s+${STANDBY_ADDR}\s+${GROUP_ADDR} -> Record
^${INTERFACE}\s+${GROUP}\s+${PRIO}\s+(?:${PREEMPT}\s+)?${STATE}\s+${ACTIVE_ADDR}\s+${STANDBY_ADDR}\s+${GROUP_ADDR}\s*$$ -> Record
^IPv6\s+Groups: -> IPv6Groups
^Interface\s+Grp\s+Pri\s+P\s+State\s+Active\s+addr\s+Standby\s+addr\s+\s+Group\s+addr\s*$$
^IPv[46]\s+Groups:
^IPv4\s+Groups:
^\s+P\s+indicates
^\s+|\s*$$
^\S+\s+\S+\s+\d+\s+\d+:\d+:\d+\.\d+\s+\S+\s*$$
^\s*$$
^. -> Error

IPv6Groups
# multiline IPv6 HSRP group
^${INTERFACE}\s+${GROUP}\s+${PRIO}\s+(?:${PREEMPT}\s+)?${STATE}\s+${ACTIVE_ADDR}(?:\s+${STANDBY_ADDR})?\s*$$
^(?:\s){45,50}${STANDBY_ADDR}\s*$$
^(?:\s){62,}${GROUP_ADDR}\s*$$ -> Record
# single line IPv6 HSRP group
^${INTERFACE}\s+${GROUP}\s+${PRIO}\s+(?:${PREEMPT}\s+)?${STATE}\s+${ACTIVE_ADDR}\s+${STANDBY_ADDR}(?:\s+${GROUP_ADDR})?\s*$$ -> Record
^Interface\s+Grp\s+Pri\s+P\s+State\s+Active\s+addr\s+Standby\s+addr\s+\s+Group\s+addr\s*$$
^\s+P\s+indicates
^\s+|\s*$$
^. -> Error
10 changes: 5 additions & 5 deletions tests/cisco_xr/show_hsrp/cisco_xr_show_hsrp.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
parsed_sample:
- interface: "Gi0/0/0/1"
- active_addr: "local"
group: "1"
prio: "110"
group_addr: "10.1.1.1"
interface: "Gi0/0/0/1"
preempt: "P"
state: "Active"
active_addr: "local"
prio: "110"
standby_addr: "10.1.1.3"
group_addr: "10.1.1.1"
state: "Active"
26 changes: 26 additions & 0 deletions tests/cisco_xr/show_hsrp/cisco_xr_show_hsrp2.raw
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Mon Jul 29 00:05:16.882 UTC
IPv4 Groups:
P indicates configured to preempt.
|
Interface Grp Pri P State Active addr Standby addr Group addr
Gi0/0/0/0 1 110 P Active local 10.0.0.3 10.0.0.1
Gi0/0/0/0.123 123 90 P Standby 10.1.2.4 local 10.1.2.1
Gi0/0/0/0.456 456 100 Active local 10.4.56.3 10.4.56.1
IPv6 Groups:
P indicates configured to preempt.
|
Interface Grp Pri P State Active addr Standby addr Group addr
Gi0/0/0/0 6 110 P Active local fe80::5054:ff:fe0d:1111
fe80::1
Gi0/0/0/0.66 66 100 Active local fe80::5054:ff:fe0d:1111
fe80::4:5:6:66
Gi0/0/0/0.123 123 90 P Standby fe80::5054:ff:fe0d:1111
local
fe80:1:2:3:4:5:6:7
Gi0/0/0/0.234 234 90 Standby fe80::5054:ff:fe0d:1111
local
fe80:7:6:5:4:3:2:1
Gi0/0/0/0.456 456 100 Active local fe80::5054:ff:fe0d:1111
fe80::4:5:6:456
Gi0/0/0/0.789 788 100 Active local fe80::9 fe80::788
Gi0/0/0/0.789 789 110 P Active local fe80::9 fe80::789
82 changes: 82 additions & 0 deletions tests/cisco_xr/show_hsrp/cisco_xr_show_hsrp2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
parsed_sample:
- active_addr: "local"
group: "1"
group_addr: "10.0.0.1"
interface: "Gi0/0/0/0"
preempt: "P"
prio: "110"
standby_addr: "10.0.0.3"
state: "Active"
- active_addr: "10.1.2.4"
group: "123"
group_addr: "10.1.2.1"
interface: "Gi0/0/0/0.123"
preempt: "P"
prio: "90"
standby_addr: "local"
state: "Standby"
- active_addr: "local"
group: "456"
group_addr: "10.4.56.1"
interface: "Gi0/0/0/0.456"
preempt: ""
prio: "100"
standby_addr: "10.4.56.3"
state: "Active"
- active_addr: "local"
group: "6"
group_addr: "fe80::1"
interface: "Gi0/0/0/0"
preempt: "P"
prio: "110"
standby_addr: "fe80::5054:ff:fe0d:1111"
state: "Active"
- active_addr: "local"
group: "66"
group_addr: "fe80::4:5:6:66"
interface: "Gi0/0/0/0.66"
preempt: ""
prio: "100"
standby_addr: "fe80::5054:ff:fe0d:1111"
state: "Active"
- active_addr: "fe80::5054:ff:fe0d:1111"
group: "123"
group_addr: "fe80:1:2:3:4:5:6:7"
interface: "Gi0/0/0/0.123"
preempt: "P"
prio: "90"
standby_addr: "local"
state: "Standby"
- active_addr: "fe80::5054:ff:fe0d:1111"
group: "234"
group_addr: "fe80:7:6:5:4:3:2:1"
interface: "Gi0/0/0/0.234"
preempt: ""
prio: "90"
standby_addr: "local"
state: "Standby"
- active_addr: "local"
group: "456"
group_addr: "fe80::4:5:6:456"
interface: "Gi0/0/0/0.456"
preempt: ""
prio: "100"
standby_addr: "fe80::5054:ff:fe0d:1111"
state: "Active"
- active_addr: "local"
group: "788"
group_addr: "fe80::788"
interface: "Gi0/0/0/0.789"
preempt: ""
prio: "100"
standby_addr: "fe80::9"
state: "Active"
- active_addr: "local"
group: "789"
group_addr: "fe80::789"
interface: "Gi0/0/0/0.789"
preempt: "P"
prio: "110"
standby_addr: "fe80::9"
state: "Active"

0 comments on commit 5c26b85

Please sign in to comment.