Skip to content

Commit 8ba274d

Browse files
author
Matt Childers
committed
Fix 3 line output for nxos ShowBgpVrfAllAllSummary
On NXOS if the IPv6 address is too long it will cause the other values to wrap to a new line. If the AS on the second line is too long (in the case of a 4-byte ASN) it will wrap to a third line. Like below: Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down... 2001:db8:c006:ff:251::1 4 406942 0 0 0 0 0 05:49:52 Idle Currently the parser will error out on 3-line cases, and this change adds a fix to parse them correctly. The fix adds a p8_2_1 regex that matches the 2nd line. In 3-line case, p8_1 will match the neighbor, the newly added p8_2_1 will match the version and AS, and the existing p8_4 will match the remaining values.
1 parent 1e2e381 commit 8ba274d

File tree

4 files changed

+287
-0
lines changed

4 files changed

+287
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--------------------------------------------------------------------------------
2+
Fix
3+
--------------------------------------------------------------------------------
4+
* NXOS
5+
* Modified ShowBgpVrfAllAllSummary:
6+
* Added support for parsing 3 lines when v6 neighbor and AS wrap to 3 lines

src/genie/libs/parser/nxos/show_bgp.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3602,6 +3602,9 @@ def cli(self, vrf='all', address_family='all', output=None):
36023602
' +(?P<outq>[0-9]+) +(?P<up_down>[a-zA-Z0-9\:]+)'
36033603
' +(?P<state_pfxrcd>(?P<state>[a-zA-Z\s\(\)]+)?(?P<prx_rcd>\d+)?([\w\(\)\s]+)?)$')
36043604
# Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
3605+
# 4 123456
3606+
p8_2_1 = re.compile(r'^\s*(?P<v>[0-9]+) +(?P<as>[0-9]+)$')
3607+
# Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
36053608
# 10.10.10.10 4 4211111111
36063609
p8_3 = re.compile(r'^\s*(?P<neighbor>[a-zA-Z0-9\.\:]+) +(?P<v>[0-9]+) +(?P<as>[0-9]+)$')
36073610
# Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
@@ -3852,6 +3855,23 @@ def cli(self, vrf='all', address_family='all', output=None):
38523855
nbr_af_dict['path']['memory_usage'] = memory_usage
38533856
continue
38543857

3858+
# Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
3859+
# 4 4211111111
3860+
m = p8_2_1.match(line)
3861+
if m and data_on_nextline:
3862+
3863+
# Add address family to this neighbor
3864+
if 'address_family' not in nbr_dict:
3865+
nbr_dict['address_family'] = {}
3866+
if address_family not in nbr_dict['address_family']:
3867+
nbr_dict['address_family'][address_family] = {}
3868+
nbr_af_dict = nbr_dict['address_family'][address_family]
3869+
3870+
# Add keys for this address_family
3871+
nbr_af_dict['neighbor_table_version'] = int(m.groupdict()['v'])
3872+
nbr_af_dict['as'] = int(m.groupdict()['as'])
3873+
continue
3874+
38553875
# Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
38563876
# 10.10.10.10 4 4211111111
38573877
m = p8_3.match(line)
Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
expected_output = {
2+
"vrf": {
3+
"default": {
4+
"neighbor": {
5+
"2001:db8:c006:0:3e57:31ff:feb8:5dc4": {
6+
"address_family": {
7+
"ipv6 unicast": {
8+
"neighbor_table_version": 4,
9+
"as": 65011,
10+
"msg_rcvd": 0,
11+
"msg_sent": 0,
12+
"tbl_ver": 0,
13+
"inq": 0,
14+
"outq": 0,
15+
"up_down": "05:49:52",
16+
"state_pfxrcd": "shut (admin)",
17+
"state": "shut (admin)",
18+
"route_identifier": "172.22.251.3",
19+
"local_as": 65101,
20+
"bgp_table_version": 47,
21+
"config_peers": 6,
22+
"capable_peers": 1,
23+
"attribute_entries": "[4/688]",
24+
"as_path_entries": "[0/0]",
25+
"community_entries": "[0/0]",
26+
"clusterlist_entries": "[0/0]",
27+
"soft_reconfig_recvd_paths": 9,
28+
"soft_reconfig_identical_paths": 9,
29+
"soft_reconfig_combo_paths": 0,
30+
"soft_reconfig_filtered_recvd": 0,
31+
"soft_reconfig_bytes": 0,
32+
"prefixes": {
33+
"total_entries": 9,
34+
"memory_usage": 3744
35+
},
36+
"path": {
37+
"total_entries": 21,
38+
"memory_usage": 3744
39+
}
40+
}
41+
}
42+
},
43+
"2001:db8:c006:ee::25": {
44+
"address_family": {
45+
"ipv6 unicast": {
46+
"neighbor_table_version": 4,
47+
"as": 65120,
48+
"msg_rcvd": 0,
49+
"msg_sent": 0,
50+
"tbl_ver": 0,
51+
"inq": 0,
52+
"outq": 0,
53+
"up_down": "05:49:52",
54+
"state_pfxrcd": "idle",
55+
"state": "idle",
56+
"route_identifier": "172.22.251.3",
57+
"local_as": 65101,
58+
"bgp_table_version": 47,
59+
"config_peers": 6,
60+
"capable_peers": 1,
61+
"attribute_entries": "[4/688]",
62+
"as_path_entries": "[0/0]",
63+
"community_entries": "[0/0]",
64+
"clusterlist_entries": "[0/0]",
65+
"soft_reconfig_recvd_paths": 9,
66+
"soft_reconfig_identical_paths": 9,
67+
"soft_reconfig_combo_paths": 0,
68+
"soft_reconfig_filtered_recvd": 0,
69+
"soft_reconfig_bytes": 0,
70+
"prefixes": {
71+
"total_entries": 9,
72+
"memory_usage": 3744
73+
},
74+
"path": {
75+
"total_entries": 21,
76+
"memory_usage": 3744
77+
}
78+
}
79+
}
80+
},
81+
"2001:db8:c006:ff:1::8": {
82+
"address_family": {
83+
"ipv6 unicast": {
84+
"neighbor_table_version": 4,
85+
"as": 65152,
86+
"msg_rcvd": 0,
87+
"msg_sent": 0,
88+
"tbl_ver": 0,
89+
"inq": 0,
90+
"outq": 0,
91+
"up_down": "05:49:52",
92+
"state_pfxrcd": "idle",
93+
"state": "idle",
94+
"route_identifier": "172.22.251.3",
95+
"local_as": 65101,
96+
"bgp_table_version": 47,
97+
"config_peers": 6,
98+
"capable_peers": 1,
99+
"attribute_entries": "[4/688]",
100+
"as_path_entries": "[0/0]",
101+
"community_entries": "[0/0]",
102+
"clusterlist_entries": "[0/0]",
103+
"soft_reconfig_recvd_paths": 9,
104+
"soft_reconfig_identical_paths": 9,
105+
"soft_reconfig_combo_paths": 0,
106+
"soft_reconfig_filtered_recvd": 0,
107+
"soft_reconfig_bytes": 0,
108+
"prefixes": {
109+
"total_entries": 9,
110+
"memory_usage": 3744
111+
},
112+
"path": {
113+
"total_entries": 21,
114+
"memory_usage": 3744
115+
}
116+
}
117+
}
118+
},
119+
"2001:db8:c006:ff:1::9": {
120+
"address_family": {
121+
"ipv6 unicast": {
122+
"neighbor_table_version": 4,
123+
"as": 65152,
124+
"msg_rcvd": 0,
125+
"msg_sent": 0,
126+
"tbl_ver": 0,
127+
"inq": 0,
128+
"outq": 0,
129+
"up_down": "05:49:52",
130+
"state_pfxrcd": "idle",
131+
"state": "idle",
132+
"route_identifier": "172.22.251.3",
133+
"local_as": 65101,
134+
"bgp_table_version": 47,
135+
"config_peers": 6,
136+
"capable_peers": 1,
137+
"attribute_entries": "[4/688]",
138+
"as_path_entries": "[0/0]",
139+
"community_entries": "[0/0]",
140+
"clusterlist_entries": "[0/0]",
141+
"soft_reconfig_recvd_paths": 9,
142+
"soft_reconfig_identical_paths": 9,
143+
"soft_reconfig_combo_paths": 0,
144+
"soft_reconfig_filtered_recvd": 0,
145+
"soft_reconfig_bytes": 0,
146+
"prefixes": {
147+
"total_entries": 9,
148+
"memory_usage": 3744
149+
},
150+
"path": {
151+
"total_entries": 21,
152+
"memory_usage": 3744
153+
}
154+
}
155+
}
156+
},
157+
"2001:db8:c006:ff:251::1": {
158+
"address_family": {
159+
"ipv6 unicast": {
160+
"neighbor_table_version": 4,
161+
"as": 406942,
162+
"msg_rcvd": 0,
163+
"msg_sent": 0,
164+
"tbl_ver": 0,
165+
"inq": 0,
166+
"outq": 0,
167+
"up_down": "05:49:52",
168+
"state_pfxrcd": "idle",
169+
"state": "idle",
170+
"route_identifier": "172.22.251.3",
171+
"local_as": 65101,
172+
"bgp_table_version": 47,
173+
"config_peers": 6,
174+
"capable_peers": 1,
175+
"attribute_entries": "[4/688]",
176+
"as_path_entries": "[0/0]",
177+
"community_entries": "[0/0]",
178+
"clusterlist_entries": "[0/0]",
179+
"soft_reconfig_recvd_paths": 9,
180+
"soft_reconfig_identical_paths": 9,
181+
"soft_reconfig_combo_paths": 0,
182+
"soft_reconfig_filtered_recvd": 0,
183+
"soft_reconfig_bytes": 0,
184+
"prefixes": {
185+
"total_entries": 9,
186+
"memory_usage": 3744
187+
},
188+
"path": {
189+
"total_entries": 21,
190+
"memory_usage": 3744
191+
}
192+
}
193+
}
194+
},
195+
"2001:db8:c006:ff:251::4": {
196+
"address_family": {
197+
"ipv6 unicast": {
198+
"neighbor_table_version": 4,
199+
"as": 65101,
200+
"msg_rcvd": 2104,
201+
"msg_sent": 2101,
202+
"tbl_ver": 47,
203+
"inq": 0,
204+
"outq": 0,
205+
"up_down": "05:49:31",
206+
"state_pfxrcd": "9",
207+
"prefix_received": "9",
208+
"state": "established",
209+
"route_identifier": "172.22.251.3",
210+
"local_as": 65101,
211+
"bgp_table_version": 47,
212+
"config_peers": 6,
213+
"capable_peers": 1,
214+
"attribute_entries": "[4/688]",
215+
"as_path_entries": "[0/0]",
216+
"community_entries": "[0/0]",
217+
"clusterlist_entries": "[0/0]",
218+
"soft_reconfig_recvd_paths": 9,
219+
"soft_reconfig_identical_paths": 9,
220+
"soft_reconfig_combo_paths": 0,
221+
"soft_reconfig_filtered_recvd": 0,
222+
"soft_reconfig_bytes": 0,
223+
"prefixes": {
224+
"total_entries": 9,
225+
"memory_usage": 3744
226+
},
227+
"path": {
228+
"total_entries": 21,
229+
"memory_usage": 3744
230+
}
231+
}
232+
}
233+
}
234+
}
235+
}
236+
}
237+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
show bgp vrf default ipv6 uni summary
2+
BGP summary information for VRF default, address family IPv6 Unicast
3+
BGP router identifier 172.22.251.3, local AS number 65101
4+
BGP table version is 47, IPv6 Unicast config peers 6, capable peers 1
5+
9 network entries and 21 paths using 3744 bytes of memory
6+
BGP attribute entries [4/688], BGP AS path entries [0/0]
7+
BGP community entries [0/0], BGP clusterlist entries [0/0]
8+
9 received paths for inbound soft reconfiguration
9+
9 identical, 0 modified, 0 filtered received paths using 0 bytes
10+
11+
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
12+
2001:db8:c006:0:3e57:31ff:feb8:5dc4
13+
4 65011 0 0 0 0 0 05:49:52 Shut (Admin)
14+
2001:db8:c006:ee::25
15+
4 65120 0 0 0 0 0 05:49:52 Idle
16+
2001:db8:c006:ff:1::8
17+
4 65152 0 0 0 0 0 05:49:52 Idle
18+
2001:db8:c006:ff:1::9
19+
4 65152 0 0 0 0 0 05:49:52 Idle
20+
2001:db8:c006:ff:251::1
21+
4 406942
22+
0 0 0 0 0 05:49:52 Idle
23+
2001:db8:c006:ff:251::4
24+
4 65101 2104 2101 47 0 0 05:49:31 9

0 commit comments

Comments
 (0)