Skip to content

PVSTP feature implementation #648

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions clear/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import click

from . import stp
from utilities_common import util_base

from . import plugins
Expand Down Expand Up @@ -124,6 +125,11 @@ def cli():
"""SONiC command line - 'Clear' command"""
pass

#
# 'STP'
#
cli.add_command(stp.spanning_tree)

#
# 'ip' group ###
#
Expand Down
41 changes: 41 additions & 0 deletions clear/stp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import click
import utilities_common.cli as clicommon

#
# This group houses Spanning_tree commands and subgroups
#
@click.group(cls=clicommon.AliasedGroup)
@click.pass_context
def spanning_tree(ctx):
'''Clear Spanning-tree counters'''
pass

@spanning_tree.group('statistics', cls=clicommon.AliasedGroup, invoke_without_command=True)
@click.pass_context
def stp_clr_stats(ctx):
if ctx.invoked_subcommand is None:
command = 'sudo stpctl clrstsall'
clicommon.run_command(command)

@stp_clr_stats.command('interface')
@click.argument('interface_name', metavar='<interface_name>', required=True)
@click.pass_context
def stp_clr_stats_intf(ctx, interface_name):
command = 'sudo stpctl clrstsintf ' + interface_name
clicommon.run_command(command)

@stp_clr_stats.command('vlan')
@click.argument('vlan_id', metavar='<vlan_id>', required=True)
@click.pass_context
def stp_clr_stats_vlan(ctx, vlan_id):
command = 'sudo stpctl clrstsvlan ' + vlan_id
clicommon.run_command(command)

@stp_clr_stats.command('vlan-interface')
@click.argument('vlan_id', metavar='<vlan_id>', required=True)
@click.argument('interface_name', metavar='<interface_name>', required=True)
@click.pass_context
def stp_clr_stats_vlan_intf(ctx, vlan_id, interface_name):
command = 'sudo stpctl clrstsvlanintf ' + vlan_id + ' ' + interface_name
clicommon.run_command(command)

2 changes: 2 additions & 0 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from . import vlan
from . import vxlan
from . import plugins
from . import stp
from .config_mgmt import ConfigMgmtDPB

# mock masic APIs for unit test
Expand Down Expand Up @@ -875,6 +876,7 @@ def config(ctx):
config.add_command(nat.nat)
config.add_command(vlan.vlan)
config.add_command(vxlan.vxlan)
config.add_command(stp.spanning_tree)

@config.command()
@click.option('-y', '--yes', is_flag=True, callback=_abort_if_false,
Expand Down
Loading