From cba11a0dadada9758f8ca3e89a94ce4b22e8f852 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Thu, 13 Sep 2018 23:33:44 -0700 Subject: [PATCH] Fix pfcwd start_default: Use config_db to get the active port list. (#319) * Fix pfcwd start_default: Use config_db to get the active port list. Remove the use of counters_db because start_default can be called on a device where no pfcwd is enabled, so the only source we can reply on to get the port info is the config_db not counters_db. Signed-off-by: Wenda Ni * Address comments: remove function get_active_ports_from_configdb, inline the operation Signed-off-by: Wenda --- pfcwd/main.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pfcwd/main.py b/pfcwd/main.py index a50cc6be5f..980cc9ea16 100644 --- a/pfcwd/main.py +++ b/pfcwd/main.py @@ -197,10 +197,9 @@ def start_default(): configdb = swsssdk.ConfigDBConnector() configdb.connect() enable = configdb.get_entry('DEVICE_METADATA', 'localhost').get('default_pfcwd_status') - countersdb = swsssdk.SonicV2Connector(host='127.0.0.1') - countersdb.connect(countersdb.COUNTERS_DB) - all_ports = get_all_ports(countersdb) + # Get active ports from Config DB + active_ports = natsorted(configdb.get_table('DEVICE_NEIGHBOR').keys()) if not enable or enable.lower() != "enable": return @@ -215,7 +214,7 @@ def start_default(): 'action': DEFAULT_ACTION } - for port in all_ports: + for port in active_ports: configdb.set_entry("PFC_WD_TABLE", port, pfcwd_info) pfcwd_info = {}