Skip to content
Merged
Changes from all commits
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
11 changes: 7 additions & 4 deletions scripts/db_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,14 @@ def __init__(self, namespace, socket=None):
self.loglevelDB.connect(self.loglevelDB.LOGLEVEL_DB)

version_info = device_info.get_sonic_version_info()
asic_type = version_info.get('asic_type')
self.asic_type = asic_type
self.asic_type = version_info.get('asic_type')
if not self.asic_type:
log.log_error("ASIC type information not obtained. DB migration will not be reliable")
self.hwsku = device_info.get_hwsku()
if not self.hwsku:
log.log_error("HWSKU information not obtained. DB migration will not be reliable")

if asic_type == "mellanox":
if self.asic_type == "mellanox":
from mellanox_buffer_migrator import MellanoxBufferMigrator
self.mellanox_buffer_migrator = MellanoxBufferMigrator(self.configDB, self.appDB, self.stateDB)

Expand Down Expand Up @@ -989,7 +992,7 @@ def common_migration_ops(self):
# removed together with calling to migrate_copp_table function.
if self.asic_type != "mellanox":
self.migrate_copp_table()
if self.asic_type == "broadcom" and 'Force10-S6100' in self.hwsku:
if self.asic_type == "broadcom" and 'Force10-S6100' in str(self.hwsku):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need to protect the possibility that self.hwsku is none?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If self.hwsku is None then str(None) will convert None to a string and in check will still work.

Alternative is (as we want to ensure self.hwsku is always a string:
if self.asic_type == "broadcom" and type(self.hwsku) = str and 'Force10-S6100' in str(self.hwsku):

self.migrate_mgmt_ports_on_s6100()
else:
log.log_notice("Asic Type: {}, Hwsku: {}".format(self.asic_type, self.hwsku))
Expand Down