forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Splitting 'show' and 'clear' parse-chains to address overlapping func…
…tionality (sonic-net#128) The following patch provides a simple mechanism to allow overlapping parse-chains to co-exist without interfering with each other. In this particular example, we are separating BGP functionality attending to the routing-stack being used in the system. As part of these changes, Quagga-based systems will exclusively rely on 'show ip/ipv6 bgp' and 'clear ip/ipv6 bgp' stanzas, whereas FRR will make use of 'show bgp ipv4/ipv6' and 'clear bgp ipv4/ipv6' ones. Also, a few bugs are getting fixed here.
- Loading branch information
1 parent
875c1a1
commit bf27881
Showing
15 changed files
with
1,110 additions
and
57 deletions.
There are no files selected for viewing
Empty file.
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,5 @@ | ||
[aliases] | ||
running-configuration=runningconfiguration | ||
running-config=runningconfiguration | ||
startup-configuration=startupconfiguration | ||
startup-config=startupconfiguration |
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,226 @@ | ||
import click | ||
from clear.main import * | ||
|
||
|
||
############################################################################### | ||
# | ||
# 'clear bgp' cli stanza | ||
# | ||
############################################################################### | ||
|
||
|
||
@cli.group(cls=AliasedGroup, default_if_no_args=True) | ||
def bgp(): | ||
"""Clear BGP peers / state""" | ||
pass | ||
|
||
|
||
# Default 'bgp' command (called if no subcommands or their aliases were passed) | ||
@bgp.command(default=True) | ||
def default(): | ||
"""Clear all BGP peers""" | ||
command = 'sudo vtysh -c "clear bgp *"' | ||
run_command(command) | ||
|
||
|
||
@bgp.group(cls=AliasedGroup, default_if_no_args=True, | ||
context_settings=CONTEXT_SETTINGS) | ||
def neighbor(): | ||
"""Clear specific BGP peers""" | ||
pass | ||
|
||
|
||
@neighbor.command(default=True) | ||
@click.argument('ipaddress', required=False) | ||
def default(ipaddress): | ||
"""Clear all BGP peers""" | ||
|
||
if ipaddress is not None: | ||
command = 'sudo vtysh -c "clear bgp {} "'.format(ipaddress) | ||
else: | ||
command = 'sudo vtysh -c "clear 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 bgp {} in"'.format(ipaddress) | ||
else: | ||
command = 'sudo vtysh -c "clear 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 bgp {} out"'.format(ipaddress) | ||
else: | ||
command = 'sudo vtysh -c "clear bgp * out"' | ||
run_command(command) | ||
|
||
|
||
@neighbor.group(cls=AliasedGroup, default_if_no_args=True, | ||
context_settings=CONTEXT_SETTINGS) | ||
def soft(): | ||
"""Soft reconfig BGP's inbound/outbound updates""" | ||
pass | ||
|
||
|
||
@soft.command(default=True) | ||
@click.argument('ipaddress', required=False) | ||
def default(ipaddress): | ||
"""Clear BGP peers soft configuration""" | ||
|
||
if ipaddress is not None: | ||
command = 'sudo vtysh -c "clear bgp {} soft "'.format(ipaddress) | ||
else: | ||
command = 'sudo vtysh -c "clear 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 bgp {} soft in"'.format(ipaddress) | ||
else: | ||
command = 'sudo vtysh -c "clear 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 bgp {} soft out"'.format(ipaddress) | ||
else: | ||
command = 'sudo vtysh -c "clear bgp * soft out"' | ||
run_command(command) | ||
|
||
|
||
############################################################################### | ||
# | ||
# 'clear bgp ipv4' cli stanza | ||
# | ||
############################################################################### | ||
|
||
|
||
@bgp.group(cls=AliasedGroup, default_if_no_args=True, | ||
context_settings=CONTEXT_SETTINGS) | ||
def ipv4(): | ||
"""Clear BGP IPv4 peers / state""" | ||
pass | ||
|
||
|
||
# Default 'bgp' command (called if no subcommands or their aliases were passed) | ||
@ipv4.command(default=True) | ||
def default(): | ||
"""Clear all IPv4 BGP peers""" | ||
command = 'sudo vtysh -c "clear bgp ipv4 *"' | ||
run_command(command) | ||
|
||
|
||
@ipv4.group(cls=AliasedGroup, default_if_no_args=True, | ||
context_settings=CONTEXT_SETTINGS) | ||
def neighbor(): | ||
"""Clear specific IPv4 BGP peers""" | ||
pass | ||
|
||
|
||
@neighbor.command(default=True) | ||
@click.argument('ipaddress', required=False) | ||
def default(ipaddress): | ||
"""Clear all IPv4 BGP peers""" | ||
|
||
if ipaddress is not None: | ||
command = 'sudo vtysh -c "clear bgp ipv4 {} "'.format(ipaddress) | ||
else: | ||
command = 'sudo vtysh -c "clear bgp ipv4 *"' | ||
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 bgp ipv4 {} in"'.format(ipaddress) | ||
else: | ||
command = 'sudo vtysh -c "clear bgp ipv4 * 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 bgp ipv4 {} out"'.format(ipaddress) | ||
else: | ||
command = 'sudo vtysh -c "clear bgp ipv4 * out"' | ||
run_command(command) | ||
|
||
|
||
@neighbor.group(cls=AliasedGroup, default_if_no_args=True, | ||
context_settings=CONTEXT_SETTINGS) | ||
def soft(): | ||
"""Soft reconfig BGP's inbound/outbound updates""" | ||
pass | ||
|
||
|
||
@soft.command(default=True) | ||
@click.argument('ipaddress', required=False) | ||
def default(ipaddress): | ||
"""Clear BGP neighbors soft configuration""" | ||
|
||
if ipaddress is not None: | ||
command = 'sudo vtysh -c "clear bgp ipv4 {} soft "'.format(ipaddress) | ||
else: | ||
command = 'sudo vtysh -c "clear bgp ipv4 * 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 bgp ipv4 {} soft in"'.format(ipaddress) | ||
else: | ||
command = 'sudo vtysh -c "clear bgp ipv4 * 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 bgp ipv4 {} soft out"'.\ | ||
format(ipaddress) | ||
else: | ||
command = 'sudo vtysh -c "clear bgp ipv4 * soft out"' | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import click | ||
from clear.main import * | ||
|
||
|
||
############################################################################### | ||
# | ||
# 'clear bgp ipv6' cli stanza | ||
# | ||
############################################################################### | ||
|
||
|
||
@bgp.group(cls=AliasedGroup, default_if_no_args=True) | ||
def ipv6(): | ||
"""Clear BGP IPv6 peers / state""" | ||
pass | ||
|
||
|
||
# Default 'bgp' command (called if no subcommands or their aliases were passed) | ||
@ipv6.command(default=True) | ||
def default(): | ||
"""Clear all IPv6 BGP peers""" | ||
command = 'sudo vtysh -c "clear bgp ipv6 *"' | ||
run_command(command) | ||
|
||
|
||
@ipv6.group(cls=AliasedGroup, default_if_no_args=True, | ||
context_settings=CONTEXT_SETTINGS) | ||
def neighbor(): | ||
"""Clear specific IPv6 BGP peers""" | ||
pass | ||
|
||
|
||
@neighbor.command(default=True) | ||
@click.argument('ipaddress', required=False) | ||
def default(ipaddress): | ||
"""Clear all IPv6 BGP peers""" | ||
|
||
if ipaddress is not None: | ||
command = 'sudo vtysh -c "clear bgp ipv6 {} "'.format(ipaddress) | ||
else: | ||
command = 'sudo vtysh -c "clear bgp ipv6 *"' | ||
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 bgp ipv6 {} in"'.format(ipaddress) | ||
else: | ||
command = 'sudo vtysh -c "clear bgp ipv6 * 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 bgp ipv6 {} out"'.format(ipaddress) | ||
else: | ||
command = 'sudo vtysh -c "clear bgp ipv6 * out"' | ||
run_command(command) | ||
|
||
|
||
@neighbor.group(cls=AliasedGroup, default_if_no_args=True, | ||
context_settings=CONTEXT_SETTINGS) | ||
def soft(): | ||
"""Soft reconfig BGP's inbound/outbound updates""" | ||
pass | ||
|
||
|
||
@soft.command(default=True) | ||
@click.argument('ipaddress', required=False) | ||
def default(ipaddress): | ||
"""Clear BGP neighbors soft configuration""" | ||
|
||
if ipaddress is not None: | ||
command = 'sudo vtysh -c "clear bgp ipv6 {} soft "'.format(ipaddress) | ||
else: | ||
command = 'sudo vtysh -c "clear bgp ipv6 * 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 bgp ipv6 {} soft in"'.format(ipaddress) | ||
else: | ||
command = 'sudo vtysh -c "clear bgp ipv6 * 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 bgp ipv6 {} soft out"' \ | ||
.format(ipaddress) | ||
else: | ||
command = 'sudo vtysh -c "clear bgp ipv6 * soft out"' | ||
run_command(command) |
Oops, something went wrong.