Skip to content

Commit

Permalink
[show] Enhance/fix 'show ip/ipv6 bgp neighbors ...' commands (sonic-n…
Browse files Browse the repository at this point in the history
  • Loading branch information
jleveque authored Jan 9, 2018
1 parent 5ad8486 commit 6823ce2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
18 changes: 13 additions & 5 deletions show/bgp_quagga_v4.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,19 @@ def summary():
# 'neighbors' subcommand ("show ip bgp neighbors")
@bgp.command()
@click.argument('ipaddress', required=False)
def neighbors(ipaddress):
@click.argument('info_type', type=click.Choice(['routes', 'advertised-routes', 'received-routes']), required=False)
def neighbors(ipaddress, info_type):
"""Show IP (IPv4) BGP neighbors"""

command = 'sudo vtysh -c "show ip bgp neighbor'

if ipaddress is not None:
command = 'sudo vtysh -c "show ip bgp neighbor {} "'.format(ipaddress)
run_command(command)
else:
run_command('sudo vtysh -c "show ip bgp neighbor"')
command += ' {}'.format(ipaddress)

# info_type is only valid if ipaddress is specified
if info_type is not None:
command += ' {}'.format(info_type)

command += '"'

run_command(command)
5 changes: 3 additions & 2 deletions show/bgp_quagga_v6.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def summary():
# 'neighbors' subcommand ("show ipv6 bgp neighbors")
@bgp.command()
@click.argument('ipaddress', required=True)
def neighbors(ipaddress):
@click.argument('info_type', type=click.Choice(['routes', 'advertised-routes', 'received-routes']), required=True)
def neighbors(ipaddress, info_type):
"""Show IPv6 BGP neighbors"""
command = 'sudo vtysh -c "show ipv6 bgp neighbor {} "'.format(ipaddress)
command = 'sudo vtysh -c "show ipv6 bgp neighbor {} {}"'.format(ipaddress, info_type)
run_command(command)

0 comments on commit 6823ce2

Please sign in to comment.