diff --git a/pfcwd/main.py b/pfcwd/main.py index 880a5f33f8..c0e10c3402 100644 --- a/pfcwd/main.py +++ b/pfcwd/main.py @@ -3,6 +3,7 @@ import click import swsssdk import os +import sys from tabulate import tabulate from natsort import natsorted @@ -194,9 +195,25 @@ def interval(poll_interval): configdb.connect() pfcwd_info = {} if poll_interval is not None: + pfcwd_table = configdb.get_table(CONFIG_DB_PFC_WD_TABLE_NAME) + entry_min = 3000 + for entry in pfcwd_table: + if("Ethernet" not in entry): + continue + detection_time_entry_value = int(configdb.get_entry(CONFIG_DB_PFC_WD_TABLE_NAME, entry).get('detection_time')) + restoration_time_entry_value = int(configdb.get_entry(CONFIG_DB_PFC_WD_TABLE_NAME, entry).get('restoration_time')) + if ((detection_time_entry_value != None) and (detection_time_entry_value < entry_min)): + entry_min = detection_time_entry_value + entry_min_str = "detection time" + if ((restoration_time_entry_value != None) and (restoration_time_entry_value < entry_min)): + entry_min = restoration_time_entry_value + entry_min_str = "restoration time" + if entry_min < poll_interval: + print >> sys.stderr, "unable to use polling interval = {}ms, value is bigger than one of the configured {} values, please choose a smaller polling_interval".format(poll_interval,entry_min_str) + exit(1) + pfcwd_info['POLL_INTERVAL'] = poll_interval - - configdb.mod_entry(CONFIG_DB_PFC_WD_TABLE_NAME, "GLOBAL", pfcwd_info) + configdb.mod_entry(CONFIG_DB_PFC_WD_TABLE_NAME, "GLOBAL", pfcwd_info) # Stop WD @cli.command()