-
Notifications
You must be signed in to change notification settings - Fork 681
/
Copy pathbgp_quagga_v6.py
39 lines (31 loc) · 1.35 KB
/
bgp_quagga_v6.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import click
from show.main import ipv6, run_command
from utilities_common.bgp_util import get_bgp_summary_extended
import utilities_common.constants as constants
import utilities_common.cli as clicommon
###############################################################################
#
# 'show ipv6 bgp' cli stanza
#
###############################################################################
@ipv6.group(cls=clicommon.AliasedGroup)
def bgp():
"""Show IPv6 BGP (Border Gateway Protocol) information"""
pass
# 'summary' subcommand ("show ipv6 bgp summary")
@bgp.command()
def summary():
"""Show summarized information of IPv6 BGP state"""
try:
device_output = run_command(['sudo', constants.RVTYSH_COMMAND, '-c', "show ipv6 bgp summary"], return_cmd=True)
get_bgp_summary_extended(device_output)
except Exception:
run_command(['sudo', constants.RVTYSH_COMMAND, '-c', "show ipv6 bgp summary"])
# 'neighbors' subcommand ("show ipv6 bgp neighbors")
@bgp.command()
@click.argument('ipaddress', required=True)
@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', constants.RVTYSH_COMMAND, '-c', "show ipv6 bgp neighbor {} {}".format(ipaddress, info_type)]
run_command(command)