diff --git a/config/main.py b/config/main.py index 26e7cc9554..57c3cef62c 100644 --- a/config/main.py +++ b/config/main.py @@ -1321,6 +1321,17 @@ def flush_configdb(namespace=DEFAULT_NAMESPACE): return client, config_db +def delete_transceiver_tables(): + tables = ["TRANSCEIVER_INFO", "TRANSCEIVER_STATUS", "TRANSCEIVER_PM", "TRANSCEIVER_FIRMWARE_INFO", "TRANSCEIVER_DOM_SENSOR", "TRANSCEIVER_DOM_THRESHOLD"] + state_db_del_pattern = "|*" + + # delete TRANSCEIVER tables from State DB + state_db = SonicV2Connector(use_unix_socket_path=True) + state_db.connect(state_db.STATE_DB, False) + for table in tables: + state_db.delete_all_by_pattern(state_db.STATE_DB, table + state_db_del_pattern) + + def migrate_db_to_lastest(namespace=DEFAULT_NAMESPACE): # Migrate DB contents to latest version db_migrator = '/usr/local/bin/db_migrator.py' @@ -1900,6 +1911,7 @@ def reload(db, filename, yes, load_sysinfo, no_service_restart, force, file_form cfg_hwsku = output.strip() client, config_db = flush_configdb(namespace) + delete_transceiver_tables() if load_sysinfo: if namespace is DEFAULT_NAMESPACE: