Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@ def reload(filename, yes, load_sysinfo, no_service_restart):
log.log_info("'reload' stopping services...")
_stop_services()

# In Single AISC platforms we have single DB service. In multi-ASIC platforms we have a global DB
# In Single ASIC platforms we have single DB service. In multi-ASIC platforms we have a global DB
# service running in the host + DB services running in each ASIC namespace created per ASIC.
# In the below logic, we get all namespaces in this platform and add an empty namespace ''
# denoting the current namespace which we are in ( the linux host )
Expand Down
23 changes: 22 additions & 1 deletion scripts/db_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
import argparse
import json
import sys
import traceback

Expand All @@ -19,7 +20,7 @@
except KeyError:
pass


INIT_CFG_FILE = '/etc/sonic/init_cfg.json'
SYSLOG_IDENTIFIER = 'db_migrator'

# Global logger instance
Expand Down Expand Up @@ -254,6 +255,24 @@ def set_version(self, version=None):
self.configDB.set_entry(self.TABLE_NAME, self.TABLE_KEY, entry)


def common_migration_ops(self):
try:
with open(INIT_CFG_FILE) as f:
init_db = json.load(f)
except Exception as e:
raise Exception(str(e))

for init_cfg_table, table_val in init_db.items():
data = self.configDB.get_table(init_cfg_table)
if data:
# Ignore overriding the values that pre-exist in configDB
continue
log.log_info("Migrating table {} from INIT_CFG to config_db".format(init_cfg_table))
# Update all tables that do not exist in configDB but are present in INIT_CFG
for init_table_key, init_table_val in table_val.items():
self.configDB.set_entry(init_cfg_table, init_table_key, init_table_val)


def migrate(self):
version = self.get_version()
log.log_info('Upgrading from version ' + version)
Expand All @@ -262,6 +281,8 @@ def migrate(self):
if next_version == version:
raise Exception('Version migrate from %s stuck in same version' % version)
version = next_version
# Perform common migration ops
self.common_migration_ops()


def main():
Expand Down