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

Extend ShowBgpAddressFamily class to parse additional BGP commands #822

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--------------------------------------------------------------------------------
Fix
--------------------------------------------------------------------------------
* IOSXR
* Modified ShowBgpAddressFamily:
* New Show Command - show bgp {address_family} community {community}
* New Show Command - show bgp {address_family} community {community} {exact_match}
* Updated regex for handling IPv6 adresses/prefixes
* Updated regex pattern for handling new lines in IPv6 address family output
40 changes: 36 additions & 4 deletions sdk_generator/outputs/github_parser.json

Large diffs are not rendered by default.

41 changes: 31 additions & 10 deletions src/genie/libs/parser/iosxr/show_bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -8696,9 +8696,16 @@ def cli(self, vrf=None, address_family=None, summary=None, value=None, output=No
# *>i10.169.1.0/24 10.64.4.4 2219 100 0 300 33299 51178 47751 {27016} e
# *>i192.168.111.0/24 10.189.99.98 0 0 i
# *> 10.7.7.7/32 10.10.10.107 0 0 65107.65107 ?
# OR
# s>i2001:718::2:99/128 195.113.156.4 0 100 0 i
# s i 195.113.156.4 0 100 0 i
# s>i2001:718::2:101/128
# 10.2.8.1 0 100 0 i
# s i 10.2.8.1 0 100 0 i
# s>i2001:718::2:116/128
p13 = re.compile(r'^(?P<status_codes>(i|s|x|S|d|h|\*|\>|\s)+)'
Kani999 marked this conversation as resolved.
Show resolved Hide resolved
r' *(?P<prefix>(?P<ip>[0-9\.\:\[\]]+)\/(?P<mask>\d+))?'
r' +(?P<next_hop>\S+) +(?P<number>[\d\.\s\{\}]+)'
r' *(?P<prefix>(?P<ip>[0-9a-f\.\:\[\]]+)\/(?P<mask>\d+))?[\n\r]*'
r' +(?P<next_hop>\S+)[\n\r]* +(?P<number>[\d\.\s\{\}]+)'
r'(?: *(?P<origin_codes>(i|e|\?)))?$')

# Processed 40 prefixes, 50 paths
Expand Down Expand Up @@ -9122,16 +9129,23 @@ class ShowBgpAddressFamily(ShowBgpAddressFamilySchema):
'''Parser for:
'show bgp'
'show bgp {address_family}'
'show bgp {address_family} community {community}'
'show bgp {address_family} community {community} {exact_match}'
'''
cli_command = [
'show bgp',
'show bgp {address_family}',
'show bgp {address_family} community {community}',
'show bgp {address_family} community {community} {exact_match}',]

cli_command = ['show bgp',
'show bgp {address_family}']

def cli(self, address_family=None, output=None):

def cli(self, address_family=None, community=None, exact_match=None, output=None):
# Execute command
if output is None:
if address_family:
if address_family and community and exact_match:
command = self.cli_command[3].format(address_family=address_family, community=community, exact_match=exact_match)
elif address_family and community:
command = self.cli_command[2].format(address_family=address_family, community=community)
elif address_family:
command = self.cli_command[1].format(address_family=address_family)
else:
command = self.cli_command[0]
Expand Down Expand Up @@ -9193,9 +9207,16 @@ def cli(self, address_family=None, output=None):
# *>i10.169.1.0/24 10.64.4.4 2219 100 0 300 33299 51178 47751 {27016} e
# *>i192.168.111.0/24 10.189.99.98 0 0 i
# *> 10.7.7.7/32 10.10.10.107 0 0 65107.65107 ?
# OR
# s>i2001:718::2:99/128 195.113.156.4 0 100 0 i
# s i 195.113.156.4 0 100 0 i
# s>i2001:718::2:101/128
# 10.2.8.1 0 100 0 i
# s i 10.2.8.1 0 100 0 i
# s>i2001:718::2:116/128
p11 = re.compile(r'^(?P<status_codes>(i|s|x|S|d|h|\*|\>|\s)+)'
Kani999 marked this conversation as resolved.
Show resolved Hide resolved
r' *(?P<prefix>(?P<ip>[0-9\.\:\[\]]+)\/(?P<mask>\d+))?'
r' +(?P<next_hop>\S+) +(?P<number>[\d\.\s\{\}]+)'
r' *(?P<prefix>(?P<ip>[0-9a-f\.\:\[\]]+)\/(?P<mask>\d+))?[\n\r]*'
r' +(?P<next_hop>\S+)[\n\r]* +(?P<number>[\d\.\s\{\}]+)'
r'(?: *(?P<origin_codes>(i|e|\?)))?$')

# Processed 40 prefixes, 50 paths
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"address_family": "ipv6 all",
"community": "1234:1234",
"exact_match": "exact_match"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
expected_output = {
'address_family': {
'ipv6_all': {
'bgp_table_version': 5530,
'generic_scan_interval': 60,
'local_as': 1234,
'non_stop_routing': True,
'nsr_initial_init_ver_status': 'reached',
'nsr_initial_initsync_version': '7',
'nsr_issu_sync_group_versions': '5530/0',
'route_distinguisher': {
'1234:1234': {
'prefix': {
'2001:0db8:85a3:0:0:0:0:1403::/48': {
'index': {
1: {
'locprf': '0',
'next_hop': '192.0.2.1',
'origin_codes': 'i',
'path': '0',
'status_codes': '*>i',
'weight': '100',
},
2: {
'locprf': '0',
'next_hop': '192.0.2.1',
'origin_codes': 'i',
'path': '0',
'status_codes': '*i',
'weight': '100',
},
},
},
'2001:0db8:85a3::/64': {
'index': {
1: {
'locprf': '0',
'next_hop': '192.0.2.1',
'origin_codes': 'i',
'path': '0',
'status_codes': '*>i',
'weight': '100',
},
2: {
'locprf': '0',
'next_hop': '192.0.2.1',
'origin_codes': 'i',
'path': '0',
'status_codes': '*i',
'weight': '100',
},
},
},
},
},
'1234:2505005': {
'prefix': {
'2001:0db8:85a3:0:0:0:0:6:10:205::/112': {
'index': {
1: {
'locprf': '100',
'metric': '4294967295',
'next_hop': '192.0.2.2',
'origin_codes': 'i',
'path': '65031',
'status_codes': '*>i',
'weight': '0',
},
2: {
'locprf': '100',
'metric': '4294967295',
'next_hop': '192.0.2.2',
'origin_codes': 'i',
'path': '65031',
'status_codes': '*i',
'weight': '0',
},
},
},
'2001:0db8:85a3:0:0:0:0:6:192:168:201::/112': {
'index': {
1: {
'locprf': '100',
'metric': '4294967295',
'next_hop': '192.0.2.2',
'origin_codes': 'i',
'path': '65031',
'status_codes': '*>i',
'weight': '0',
},
2: {
'locprf': '100',
'metric': '4294967295',
'next_hop': '192.0.2.2',
'origin_codes': 'i',
'path': '65031',
'status_codes': '*i',
'weight': '0',
},
},
},
'2001:0db8:85a3:0:0:0:0:6:195:113:123:128:0/112': {
'index': {
1: {
'locprf': '100',
'metric': '4294967295',
'next_hop': '192.0.2.2',
'origin_codes': 'i',
'path': '65031',
'status_codes': '*>i',
'weight': '0',
},
2: {
'locprf': '100',
'metric': '4294967295',
'next_hop': '192.0.2.2',
'origin_codes': 'i',
'path': '65031',
'status_codes': '*i',
'weight': '0',
},
},
},
'2001:0db8:85a3:0:0:0:0:6:195:113:123:80/125': {
'index': {
1: {
'locprf': '100',
'metric': '4294967295',
'next_hop': '192.0.2.2',
'origin_codes': 'i',
'path': '65031',
'status_codes': '*>i',
'weight': '0',
},
2: {
'locprf': '100',
'metric': '4294967295',
'next_hop': '192.0.2.2',
'origin_codes': 'i',
'path': '65031',
'status_codes': '*i',
'weight': '0',
},
},
},
'2001:0db8:85a3:0:0:0:0:6:195:113:123:96:0/112': {
'index': {
1: {
'locprf': '100',
'metric': '4294967295',
'next_hop': '192.0.2.2',
'origin_codes': 'i',
'path': '65031',
'status_codes': '*>i',
'weight': '0',
},
2: {
'locprf': '100',
'metric': '4294967295',
'next_hop': '192.0.2.2',
'origin_codes': 'i',
'path': '65031',
'status_codes': '*i',
'weight': '0',
},
},
},
'2001:0db8:85a3:0:0:0:0:6::10/127': {
'index': {
1: {
'locprf': '0',
'next_hop': '192.0.2.2',
'origin_codes': 'i',
'path': '0',
'status_codes': '*>i',
'weight': '100',
},
2: {
'locprf': '0',
'next_hop': '192.0.2.2',
'origin_codes': 'i',
'path': '0',
'status_codes': '*i',
'weight': '100',
},
},
},
},
},
'1234:2505118': {
'prefix': {
'2001:0db8:85a3:0:0:0:0:18::/56': {
'index': {
1: {
'locprf': '100',
'next_hop': '203.0.113.7',
'origin_codes': 'i',
'path': '0',
'status_codes': '*>i',
'weight': '100',
},
2: {
'locprf': '100',
'next_hop': '203.0.113.7',
'origin_codes': 'i',
'path': '0',
'status_codes': '*i',
'weight': '100',
},
},
},
'2001:0db8:85a3:0:0:0:0:1e08::/48': {
'index': {
1: {
'locprf': '100',
'next_hop': '203.0.113.7',
'origin_codes': 'i',
'path': '0',
'status_codes': '*>i',
'weight': '100',
},
2: {
'locprf': '100',
'next_hop': '203.0.113.7',
'origin_codes': 'i',
'path': '0',
'status_codes': '*i',
'weight': '100',
},
},
},
},
},
},
'router_identifier': '192.168.1.1',
'scan_interval': 60,
'table_state': 'active',
},
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
RP/0/RSP0/CPU0:router# show bgp ivp6 all community 1234:1234 exact-match
Address Family: VPNv6 Unicast
-----------------------------

BGP router identifier 192.168.1.1, local AS number 1234
BGP generic scan interval 60 secs
Non-stop routing is enabled
BGP table state: Active
Table ID: 0x0
BGP main routing table version 5530
BGP NSR Initial initsync version 7 (Reached)
BGP NSR/ISSU Sync-Group versions 5530/0
BGP scan interval 60 secs

Status codes: s suppressed, d damped, h history, * valid, > best i - internal, r RIB-failure, S stale, N Nexthop-discard
Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 1234:1234
Route Distinguisher Version: 53
*>i2001:0db8:85a3::/64 192.0.2.1 0 100 0 i
* i 192.0.2.1 0 100 0 i
*>i2001:0db8:85a3:0:0:0:0:1403::/48 192.0.2.1 0 100 0 i
* i 192.0.2.1 0 100 0 i
Route Distinguisher: 1234:2505005
Route Distinguisher Version: 54
*>i2001:0db8:85a3:0:0:0:0:6::10/127 192.0.2.2 0 100 0 i
* i 192.0.2.2 0 100 0 i
*>i2001:0db8:85a3:0:0:0:0:6:195:113:123:80/125 192.0.2.2 4294967295 100 0 65031 i
* i 192.0.2.2 4294967295 100 0 65031 i
*>i2001:0db8:85a3:0:0:0:0:6:10:205::/112 192.0.2.2 4294967295 100 0 65031 i
* i 192.0.2.2 4294967295 100 0 65031 i
*>i2001:0db8:85a3:0:0:0:0:6:192:168:201::/112 192.0.2.2 4294967295 100 0 65031 i
* i 192.0.2.2 4294967295 100 0 65031 i
*>i2001:0db8:85a3:0:0:0:0:6:195:113:123:96:0/112 192.0.2.2 4294967295 100 0 65031 i
* i 192.0.2.2 4294967295 100 0 65031 i
*>i2001:0db8:85a3:0:0:0:0:6:195:113:123:128:0/112 192.0.2.2 4294967295 100 0 65031 i
* i 192.0.2.2 4294967295 100 0 65031 i
Route Distinguisher: 1234:2505118
Route Distinguisher Version: 49
*>i2001:0db8:85a3:0:0:0:0:18::/56 203.0.113.7 100 100 0 i
* i 203.0.113.7 100 100 0 i
*>i2001:0db8:85a3:0:0:0:0:1e08::/48 203.0.113.7 100 100 0 i
* i 203.0.113.7 100 100 0 i
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"vrf": "xNet",
"address_family": "ipv6 unicast"
}
Loading
Loading