Skip to content

Commit

Permalink
Run pfcwd only on ports where pfc is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ayurkiv-nvda committed Mar 4, 2021
1 parent c7e46c9 commit 2f83dad
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pfcwd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
CONFIG_HEADER = ('PORT',) + list(zip(*CONFIG_DESCRIPTION))[0]

CONFIG_DB_PFC_WD_TABLE_NAME = 'PFC_WD'

PORT_QOS_MAP = "PORT_QOS_MAP"

# Main entrypoint
@click.group()
Expand Down Expand Up @@ -242,6 +242,10 @@ def start(self, action, restoration_time, ports, detection_time):
exit()
self.start_cmd(action, restoration_time, ports, detection_time)

def get_port_pfc_status(self, port):
status = self.config_db.get_entry(PORT_QOS_MAP, port).get('pfc_enable')
return status

@multi_asic_util.run_on_multi_asic
def start_cmd(self, action, restoration_time, ports, detection_time):
if os.geteuid() != 0:
Expand Down Expand Up @@ -272,15 +276,23 @@ def start_cmd(self, action, restoration_time, ports, detection_time):
for port in ports:
if port == "all":
for p in all_ports:
pfc_status = self.get_port_pfc_status(p)
if pfc_status == None:
print("SKIPPED: PFC is not enabled on port: {}".format(p))
continue

self.config_db.mod_entry(
CONFIG_DB_PFC_WD_TABLE_NAME, p, None
)
self.config_db.mod_entry(
CONFIG_DB_PFC_WD_TABLE_NAME, p, pfcwd_info
)
else:
if port not in all_ports:
pfc_status = self.get_port_pfc_status(port)
if port not in all_ports or pfc_status == None:
print("SKIPPED: PFC is not enabled on port: {}".format(port))
continue

self.config_db.mod_entry(
CONFIG_DB_PFC_WD_TABLE_NAME, port, None
)
Expand Down

0 comments on commit 2f83dad

Please sign in to comment.