forked from sonic-net/sonic-utilities
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbgp_quagga_v4.py
103 lines (77 loc) · 2.49 KB
/
bgp_quagga_v4.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import click
from clear.main import ip, run_command
###############################################################################
#
# 'clear ip bgp' cli stanza
#
###############################################################################
@ip.group()
def bgp():
"""Clear BGP (Border Gateway Protocol) peers"""
pass
@bgp.group()
def neighbor():
"""Clear specific BGP peers"""
pass
@neighbor.command('all')
@click.argument('ipaddress', required=False)
def neigh_all(ipaddress):
"""Clear all BGP peers"""
if ipaddress is not None:
command = 'sudo vtysh -c "clear ip bgp {}"'.format(ipaddress)
else:
command = 'sudo vtysh -c "clear ip bgp *"'
run_command(command)
# 'in' subcommand
@neighbor.command('in')
@click.argument('ipaddress', required=False)
def neigh_in(ipaddress):
"""Send route-refresh"""
if ipaddress is not None:
command = 'sudo vtysh -c "clear ip bgp {} in"'.format(ipaddress)
else:
command = 'sudo vtysh -c "clear ip bgp * in"'
run_command(command)
# 'out' subcommand
@neighbor.command('out')
@click.argument('ipaddress', required=False)
def neigh_out(ipaddress):
"""Resend all outbound updates"""
if ipaddress is not None:
command = 'sudo vtysh -c "clear ip bgp {} out"'.format(ipaddress)
else:
command = 'sudo vtysh -c "clear ip bgp * out"'
run_command(command)
@neighbor.group()
def soft():
"""Soft reconfig BGP's inbound/outbound updates"""
pass
@soft.command('all')
@click.argument('ipaddress', required=False)
def soft_all(ipaddress):
"""Clear BGP neighbors soft configuration"""
if ipaddress is not None:
command = 'sudo vtysh -c "clear ip bgp {} soft"'.format(ipaddress)
else:
command = 'sudo vtysh -c "clear ip bgp * soft"'
run_command(command)
# 'soft in' subcommand
@soft.command('in')
@click.argument('ipaddress', required=False)
def soft_in(ipaddress):
"""Send route-refresh"""
if ipaddress is not None:
command = 'sudo vtysh -c "clear ip bgp {} soft in"'.format(ipaddress)
else:
command = 'sudo vtysh -c "clear ip bgp * soft in"'
run_command(command)
# 'soft out' subcommand
@soft.command('out')
@click.argument('ipaddress', required=False)
def soft_out(ipaddress):
"""Resend all outbound updates"""
if ipaddress is not None:
command = 'sudo vtysh -c "clear ip bgp {} soft out"'.format(ipaddress)
else:
command = 'sudo vtysh -c "clear ip bgp * soft out"'
run_command(command)