From 08da428fb84529bbf3f81d7183c6cd5444090d2d Mon Sep 17 00:00:00 2001 From: sihuihan88 Date: Mon, 16 Apr 2018 11:15:24 -0700 Subject: [PATCH] [pfcwd]: add cli to enable/disable BIG_RED_SWITCH mode (#237) Signed-off-by: Sihui Han --- pfcwd/main.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pfcwd/main.py b/pfcwd/main.py index d5d39caaae50..5e94d8cd13e9 100644 --- a/pfcwd/main.py +++ b/pfcwd/main.py @@ -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 @@ -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()