-
Notifications
You must be signed in to change notification settings - Fork 684
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[show][bgp] Use only 'show ip bgp' as the base and use bgp_frr_v4 fil…
…e for FRR routing stack (#884) Co-authored-by: Travis Van Duyn <trvanduy@microsoft.com>
- Loading branch information
Showing
2 changed files
with
51 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import click | ||
from show.main import ip, run_command, get_bgp_summary_extended | ||
|
||
|
||
############################################################################### | ||
# | ||
# 'show ip bgp' cli stanza | ||
# | ||
############################################################################### | ||
|
||
|
||
@ip.group() | ||
def bgp(): | ||
"""Show IPv4 BGP (Border Gateway Protocol) information""" | ||
pass | ||
|
||
|
||
# 'summary' subcommand ("show ip bgp summary") | ||
@bgp.command() | ||
def summary(): | ||
"""Show summarized information of IPv4 BGP state""" | ||
try: | ||
device_output = run_command('sudo vtysh -c "show ip bgp summary"', return_cmd=True) | ||
get_bgp_summary_extended(device_output) | ||
except Exception: | ||
run_command('sudo vtysh -c "show ip bgp summary"') | ||
|
||
|
||
# 'neighbors' subcommand ("show ip bgp neighbors") | ||
@bgp.command() | ||
@click.argument('ipaddress', required=False) | ||
@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 += ' {}'.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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters