Skip to content

Commit cba11a0

Browse files
wendanilguohan
authored andcommitted
Fix pfcwd start_default: Use config_db to get the active port list. (sonic-net#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 <[email protected]> * Address comments: remove function get_active_ports_from_configdb, inline the operation Signed-off-by: Wenda <[email protected]>
1 parent 53c0007 commit cba11a0

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

pfcwd/main.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,9 @@ def start_default():
197197
configdb = swsssdk.ConfigDBConnector()
198198
configdb.connect()
199199
enable = configdb.get_entry('DEVICE_METADATA', 'localhost').get('default_pfcwd_status')
200-
countersdb = swsssdk.SonicV2Connector(host='127.0.0.1')
201-
countersdb.connect(countersdb.COUNTERS_DB)
202200

203-
all_ports = get_all_ports(countersdb)
201+
# Get active ports from Config DB
202+
active_ports = natsorted(configdb.get_table('DEVICE_NEIGHBOR').keys())
204203

205204
if not enable or enable.lower() != "enable":
206205
return
@@ -215,7 +214,7 @@ def start_default():
215214
'action': DEFAULT_ACTION
216215
}
217216

218-
for port in all_ports:
217+
for port in active_ports:
219218
configdb.set_entry("PFC_WD_TABLE", port, pfcwd_info)
220219

221220
pfcwd_info = {}

0 commit comments

Comments
 (0)