Skip to content

Commit

Permalink
Change PFC watchdog CONFIG_DB table name from PFC_WD_TABLE to PFC_WD (#…
Browse files Browse the repository at this point in the history
…475)

* Change PFC watchdog CONFIG_DB table name from PFC_WD_TABLE to PFC_WD

Signed-off-by: Wenda Ni <wenni@microsoft.com>
  • Loading branch information
wendani authored and lguohan committed Mar 22, 2019
1 parent 1b734f1 commit d347527
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions pfcwd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
STATS_HEADER = ('QUEUE',) + zip(*STATS_DESCRIPTION)[0]
CONFIG_HEADER = ('PORT',) + zip(*CONFIG_DESCRIPTION)[0]

CONFIG_DB_PFC_WD_TABLE_NAME = 'PFC_WD'

# Main entrypoint
@click.group()
def cli():
Expand Down Expand Up @@ -104,18 +106,18 @@ def config(ports):

for port in ports:
config_list = []
config_entry = configdb.get_entry('PFC_WD_TABLE', port)
config_entry = configdb.get_entry(CONFIG_DB_PFC_WD_TABLE_NAME, port)
if config_entry is None or config_entry == {}:
continue
for config in CONFIG_DESCRIPTION:
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')
poll_interval = configdb.get_entry( CONFIG_DB_PFC_WD_TABLE_NAME, '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')
big_red_switch = configdb.get_entry( CONFIG_DB_PFC_WD_TABLE_NAME, 'GLOBAL').get('BIG_RED_SWITCH')
if big_red_switch is not None:
click.echo("BIG_RED_SWITCH status is " + big_red_switch)

Expand Down Expand Up @@ -167,13 +169,13 @@ def start(action, restoration_time, ports, detection_time):
for port in ports:
if port == "all":
for p in all_ports:
configdb.mod_entry("PFC_WD_TABLE", p, None)
configdb.mod_entry("PFC_WD_TABLE", p, pfcwd_info)
configdb.mod_entry(CONFIG_DB_PFC_WD_TABLE_NAME, p, None)
configdb.mod_entry(CONFIG_DB_PFC_WD_TABLE_NAME, p, pfcwd_info)
else:
if port not in all_ports:
continue
configdb.mod_entry("PFC_WD_TABLE", port, None)
configdb.mod_entry("PFC_WD_TABLE", port, pfcwd_info)
configdb.mod_entry(CONFIG_DB_PFC_WD_TABLE_NAME, port, None)
configdb.mod_entry(CONFIG_DB_PFC_WD_TABLE_NAME, port, pfcwd_info)

# Set WD poll interval
@cli.command()
Expand All @@ -188,7 +190,7 @@ def interval(poll_interval):
if poll_interval is not None:
pfcwd_info['POLL_INTERVAL'] = poll_interval

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

# Stop WD
@cli.command()
Expand All @@ -210,7 +212,7 @@ def stop(ports):
for port in ports:
if port not in all_ports:
continue
configdb.mod_entry("PFC_WD_TABLE", port, None)
configdb.mod_entry(CONFIG_DB_PFC_WD_TABLE_NAME, port, None)

# Set WD default configuration on server facing ports when enable flag is on
@cli.command()
Expand Down Expand Up @@ -239,11 +241,11 @@ def start_default():
}

for port in active_ports:
configdb.set_entry("PFC_WD_TABLE", port, pfcwd_info)
configdb.set_entry(CONFIG_DB_PFC_WD_TABLE_NAME, port, pfcwd_info)

pfcwd_info = {}
pfcwd_info['POLL_INTERVAL'] = DEFAULT_POLL_INTERVAL * multiply
configdb.mod_entry("PFC_WD_TABLE", "GLOBAL", pfcwd_info)
configdb.mod_entry(CONFIG_DB_PFC_WD_TABLE_NAME, "GLOBAL", pfcwd_info)

# Enable/disable PFC WD counter polling
@cli.command()
Expand Down Expand Up @@ -271,7 +273,7 @@ def big_red_switch(big_red_switch):
if big_red_switch is not None:
pfcwd_info['BIG_RED_SWITCH'] = big_red_switch

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

if __name__ == '__main__':
cli()

0 comments on commit d347527

Please sign in to comment.