Skip to content
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

[pfcwd]: add command to set pfcwd polling interval #192

Merged
merged 1 commit into from
Feb 9, 2018
Merged
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
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')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does someone write default value there or should we check if it's not empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to display only when the value is changed.

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