Skip to content

Commit

Permalink
[pfcwd]: add cli to enable/disable BIG_RED_SWITCH mode (sonic-net#237)
Browse files Browse the repository at this point in the history
Signed-off-by: Sihui Han <sihan@microsoft.com>
  • Loading branch information
sihuihan88 authored and lguohan committed Apr 27, 2018
1 parent ca11c15 commit 08da428
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pfcwd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ def config(ports):
poll_interval = configdb.get_entry( 'PFC_WD_TABLE', 'GLOBAL').get('POLL_INTERVAL')
if poll_interval is not None:
click.echo("Changed polling interval to " + poll_interval + "ms")

big_red_switch = configdb.get_entry( 'PFC_WD_TABLE', 'GLOBAL').get('BIG_RED_SWITCH')
if big_red_switch is not None:
click.echo("BIG_RED_SWITCH status is " + big_red_switch)

click.echo(tabulate(table, CONFIG_HEADER, stralign='right', numalign='right', tablefmt='simple'))

# Start WD
Expand Down Expand Up @@ -214,5 +219,18 @@ def start_default():
pfcwd_info['POLL_INTERVAL'] = DEFAULT_POLL_INTERVAL * multiply
configdb.mod_entry("PFC_WD_TABLE", "GLOBAL", pfcwd_info)

# Enable/disable PFC WD BIG_RED_SWITCH mode
@cli.command()
@click.argument('big_red_switch', type=click.Choice(['enable', 'disable']))
def big_red_switch(big_red_switch):
""" Enable/disable BIG_RED_SWITCH mode """
configdb = swsssdk.ConfigDBConnector()
configdb.connect()
pfcwd_info = {}
if big_red_switch is not None:
pfcwd_info['BIG_RED_SWITCH'] = big_red_switch

configdb.mod_entry("PFC_WD_TABLE", "GLOBAL", pfcwd_info)

if __name__ == '__main__':
cli()

0 comments on commit 08da428

Please sign in to comment.