diff --git a/scripts/db_migrator.py b/scripts/db_migrator.py index 97e6175c17..34922b5256 100755 --- a/scripts/db_migrator.py +++ b/scripts/db_migrator.py @@ -45,7 +45,7 @@ def __init__(self, namespace, socket=None): none-zero values. build: sequentially increase within a minor version domain. """ - self.CURRENT_VERSION = 'version_2_0_5' + self.CURRENT_VERSION = 'version_2_0_0' self.TABLE_NAME = 'VERSIONS' self.TABLE_KEY = 'DATABASE' @@ -409,6 +409,18 @@ def prepare_dynamic_buffer_for_warm_reboot(self, buffer_pools=None, buffer_profi return True + def migrate_pfcwd_sw_enable_table(self): + """ + Migrate "pfc_enable" to "pfc_enable" and "pfcwd_sw_enable" + 1. pfc_enable means enable pfc on certain queues + 2. pfcwd_sw_enable means enable PFC software watchdog on certain queues + """ + qos_maps = self.configDB.get_table('PORT_QOS_MAP') + for k, v in qos_maps.items(): + if 'pfc_enable' in v: + v['pfcwd_sw_enable'] = v['pfc_enable'] + self.configDB.set_entry('PORT_QOS_MAP', k, v) + def version_unknown(self): """ version_unknown tracks all SONiC versions that doesn't have a version @@ -544,65 +556,10 @@ def version_1_0_6(self): return 'version_2_0_0' def version_2_0_0(self): - """ - Version 2_0_0 (A dummy migrator). - """ - log.log_info('Handling version_2_0_0') - - self.set_version('version_2_0_1') - return 'version_2_0_1' - - def version_2_0_1(self): - """ - Version 2_0_1 (A dummy migrator). - """ - log.log_info('Handling version_2_0_1') - - self.set_version('version_2_0_2') - return 'version_2_0_2' - - def version_2_0_2(self): - """ - Version 2_0_2 (A dummy migrator). - """ - log.log_info('Handling version_2_0_2') - - self.set_version('version_2_0_3') - return 'version_2_0_3' - - def version_2_0_3(self): - """ - Version 2_0_3 (A dummy migrator). - """ - log.log_info('Handling version_2_0_3') - - self.set_version('version_2_0_4') - return 'version_2_0_4' - - def version_2_0_4(self): - """ - Version 2_0_4 - """ - log.log_info('Handling version_2_0_4') - # Migrate "pfc_enable" to "pfc_enable" and "pfcwd_sw_enable" - # 1. pfc_enable means enable pfc on certain queues - # 2. pfcwd_sw_enable means enable PFC software watchdog on certain queues - # By default, PFC software watchdog is enabled on all pfc enabled queues. - qos_maps = self.configDB.get_table('PORT_QOS_MAP') - for k, v in qos_maps.items(): - if 'pfc_enable' in v: - v['pfcwd_sw_enable'] = v['pfc_enable'] - self.configDB.set_entry('PORT_QOS_MAP', k, v) - self.set_version('version_2_0_5') - - return 'version_2_0_5' - - def version_2_0_5(self): """ Current latest version. Nothing to do here. """ - log.log_info('Handling version_2_0_5') - return None + log.log_info('Handling version_2_0_0') def get_version(self): version = self.configDB.get_entry(self.TABLE_NAME, self.TABLE_KEY) @@ -652,6 +609,9 @@ def common_migration_ops(self): # version 2_0_1 has been occupied by 202106 if self.asic_type == "mellanox": self.mellanox_buffer_migrator.mlnx_reclaiming_unused_buffer() + + # Migrate pfcwd_sw_enable table + self.migrate_pfcwd_sw_enable_table() def migrate(self): version = self.get_version() diff --git a/tests/db_migrator_input/config_db/qos_map_table_expected.json b/tests/db_migrator_input/config_db/qos_map_table_expected.json index 946f7f02d9..0a74fb5a7d 100644 --- a/tests/db_migrator_input/config_db/qos_map_table_expected.json +++ b/tests/db_migrator_input/config_db/qos_map_table_expected.json @@ -1,6 +1,6 @@ { "VERSIONS|DATABASE": { - "VERSION": "version_2_0_5" + "VERSION": "version_2_0_0" }, "PORT_QOS_MAP": { "Ethernet0": { diff --git a/tests/db_migrator_input/config_db/qos_map_table_input.json b/tests/db_migrator_input/config_db/qos_map_table_input.json index c7dbce9658..fb4edffe1d 100644 --- a/tests/db_migrator_input/config_db/qos_map_table_input.json +++ b/tests/db_migrator_input/config_db/qos_map_table_input.json @@ -1,6 +1,6 @@ { "VERSIONS|DATABASE": { - "VERSION": "version_2_0_4" + "VERSION": "version_2_0_0" }, "PORT_QOS_MAP": { "Ethernet0": {