Skip to content

Commit

Permalink
[pfcwd]: add command to set pfcwd polling interval (#192)
Browse files Browse the repository at this point in the history
Signed-off-by: Sihui Han <sihan@microsoft.com>
  • Loading branch information
sihuihan88 committed Feb 9, 2018
1 parent db80717 commit dac636f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pfcwd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ def config(ports):
line = config_entry.get(config[1], config[2])
config_list.append(line)
table.append([port] + config_list)

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")
click.echo(tabulate(table, CONFIG_HEADER, stralign='right', numalign='right', tablefmt='simple'))

# Start WD
Expand Down Expand Up @@ -127,6 +129,19 @@ def start(action, restoration_time, ports, detection_time):
configdb.mod_entry("PFC_WD_TABLE", port, None)
configdb.mod_entry("PFC_WD_TABLE", port, pfcwd_info)

# Set WD poll interval
@cli.command()
@click.argument('poll_interval', type=click.IntRange(100, 3000))
def interval(poll_interval):
""" Set PFC watchdog counter polling interval """
configdb = swsssdk.ConfigDBConnector()
configdb.connect()
pfcwd_info = {}
if poll_interval is not None:
pfcwd_info['POLL_INTERVAL'] = poll_interval

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

# Stop WD
@cli.command()
@click.argument('ports', nargs = -1)
Expand Down

0 comments on commit dac636f

Please sign in to comment.