Skip to content

Commit cbd956d

Browse files
nikos-githublguohan
authored andcommitted
FRR: fix show bgp and clear bgp to provide the full set of cli options available (#149)
1 parent a4087dd commit cbd956d

6 files changed

Lines changed: 27 additions & 546 deletions

File tree

clear/bgp_frr_v4.py

Lines changed: 0 additions & 226 deletions
This file was deleted.

clear/bgp_frr_v6.py

Lines changed: 0 additions & 114 deletions
This file was deleted.

clear/main.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,20 +151,29 @@ def ipv6():
151151

152152

153153
#
154-
# Inserting BGP functionality into cli's clear parse-chain. The insertion point
155-
# and the specific BGP commands to import, will be determined by the routing-stack
156-
# being elected.
154+
# Inserting BGP functionality into cli's clear parse-chain.
155+
# BGP commands are determined by the routing-stack being elected.
157156
#
158157
if routing_stack == "quagga":
159158
from .bgp_quagga_v4 import bgp
160159
ip.add_command(bgp)
161160
from .bgp_quagga_v6 import bgp
162161
ipv6.add_command(bgp)
163162
elif routing_stack == "frr":
164-
from .bgp_frr_v4 import bgp
165-
cli.add_command(bgp)
166-
from .bgp_frr_v6 import bgp
167-
cli.add_command(bgp)
163+
@cli.command()
164+
@click.argument('bgp_args', nargs = -1, required = False)
165+
def bgp(bgp_args):
166+
"""BGP information"""
167+
bgp_cmd = "clear bgp"
168+
options = False
169+
for arg in bgp_args:
170+
bgp_cmd += " " + str(arg)
171+
options = True
172+
if options is True:
173+
command = 'sudo vtysh -c "{}"'.format(bgp_cmd)
174+
else:
175+
command = 'sudo vtysh -c "clear bgp *"'
176+
run_command(command)
168177

169178

170179
@cli.command()

0 commit comments

Comments
 (0)