Skip to content

Commit 80d4698

Browse files
authored
Delete TRSNCEIVER tables while config reload (sonic-net#3680)
* Delete TRANSCEIVER tables while config reload
1 parent bf6ff9f commit 80d4698

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

config/main.py

+14
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,18 @@ def flush_configdb(namespace=DEFAULT_NAMESPACE):
13221322
return client, config_db
13231323

13241324

1325+
def delete_transceiver_tables():
1326+
tables = ["TRANSCEIVER_INFO", "TRANSCEIVER_STATUS", "TRANSCEIVER_PM",
1327+
"TRANSCEIVER_FIRMWARE_INFO", "TRANSCEIVER_DOM_SENSOR", "TRANSCEIVER_DOM_THRESHOLD"]
1328+
state_db_del_pattern = "|*"
1329+
1330+
# delete TRANSCEIVER tables from State DB
1331+
state_db = SonicV2Connector(use_unix_socket_path=True)
1332+
state_db.connect(state_db.STATE_DB, False)
1333+
for table in tables:
1334+
state_db.delete_all_by_pattern(state_db.STATE_DB, table + state_db_del_pattern)
1335+
1336+
13251337
def migrate_db_to_lastest(namespace=DEFAULT_NAMESPACE):
13261338
# Migrate DB contents to latest version
13271339
db_migrator = '/usr/local/bin/db_migrator.py'
@@ -1905,6 +1917,7 @@ def reload(db, filename, yes, load_sysinfo, no_service_restart, force, file_form
19051917
cfg_hwsku = output.strip()
19061918

19071919
client, config_db = flush_configdb(namespace)
1920+
delete_transceiver_tables()
19081921

19091922
if load_sysinfo:
19101923
if namespace is DEFAULT_NAMESPACE:
@@ -2037,6 +2050,7 @@ def load_minigraph(db, no_service_restart, traffic_shift_away, override_config,
20372050
# Stop services before config push
20382051
if not no_service_restart:
20392052
log.log_notice("'load_minigraph' stopping services...")
2053+
delete_transceiver_tables()
20402054
_stop_services()
20412055

20422056
# For Single Asic platform the namespace list has the empty string

0 commit comments

Comments
 (0)