From 2e4c89696ecff5399f061e87aa642dc840356f28 Mon Sep 17 00:00:00 2001 From: Abhishek Dosi Date: Mon, 7 Jun 2021 09:10:05 -0700 Subject: [PATCH] =?UTF-8?q?Revert=20"[201911][db=5Fmigrator]=20fix=20old?= =?UTF-8?q?=201911=20feature=20config=20migration=20to=20a=20new=20?= =?UTF-8?q?=E2=80=A6=20(#1637)"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 42354e6755d7202cd6f700510c0690d4230e4cf9. --- scripts/db_migrator.py | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/scripts/db_migrator.py b/scripts/db_migrator.py index 3f5ab19220..ba9b9eea2e 100755 --- a/scripts/db_migrator.py +++ b/scripts/db_migrator.py @@ -154,21 +154,6 @@ def migrate_intf_table(self): self.appDB.set(self.appDB.APPL_DB, table, 'NULL', 'NULL') if_db.append(if_name) - def migrate_feature_table(self): - ''' - Combine CONTAINER_FEATURE and FEATURE tables into FEATURE table. - ''' - feature_table = self.configDB.get_table('FEATURE') - for feature, config in feature_table.items(): - state = config.pop('status', 'disabled') - config['state'] = state - self.configDB.set_entry('FEATURE', feature, config) - - container_feature_table = self.configDB.get_table('CONTAINER_FEATURE') - for feature, config in container_feature_table.items(): - self.configDB.mod_entry('FEATURE', feature, config) - self.configDB.set_entry('CONTAINER_FEATURE', feature, None) - def version_unknown(self): """ version_unknown tracks all SONiC versions that doesn't have a version @@ -222,8 +207,6 @@ def version_1_0_3(self): """ log.log_info('Handling version_1_0_3') - self.migrate_feature_table() - # Check ASIC type, if Mellanox platform then need DB migration if self.asic_type == "mellanox": if self.mellanox_buffer_migrator.mlnx_migrate_buffer_pool_size('version_1_0_3', 'version_1_0_4') and self.mellanox_buffer_migrator.mlnx_migrate_buffer_profile('version_1_0_3', 'version_1_0_4'): @@ -263,6 +246,7 @@ def get_version(self): return 'version_unknown' + def set_version(self, version=None): if not version: version = self.CURRENT_VERSION @@ -270,6 +254,7 @@ def set_version(self, version=None): entry = { self.TABLE_FIELD : version } self.configDB.set_entry(self.TABLE_NAME, self.TABLE_KEY, entry) + def common_migration_ops(self): try: with open(INIT_CFG_FILE) as f: @@ -278,16 +263,15 @@ def common_migration_ops(self): 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)) - for key in table_val: - curr_cfg = self.configDB.get_entry(init_cfg_table, key) - init_cfg = table_val[key] - - # Override init config with current config. - # This will leave new fields from init_config - # in new_config, but not override existing configuration. - new_cfg = {**init_cfg, **curr_cfg} - self.configDB.set_entry(init_cfg_table, key, new_cfg) + # 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()