Skip to content

Commit

Permalink
[warmboot] Migrate 10G ports during warm-reboot on s6100 (sonic-net#2064
Browse files Browse the repository at this point in the history
)
  • Loading branch information
tjchadaga committed Mar 1, 2022
1 parent 494c6d7 commit d440df7
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions scripts/db_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def __init__(self, namespace, socket=None):
version_info = device_info.get_sonic_version_info()
asic_type = version_info.get('asic_type')
self.asic_type = asic_type
self.hwsku = device_info.get_hwsku()

if asic_type == "mellanox":
from mellanox_buffer_migrator import MellanoxBufferMigrator
Expand Down Expand Up @@ -125,6 +126,43 @@ def migrate_interface_table(self):
self.configDB.set_entry(table, key[0], data[key])
if_db.append(key[0])

def migrate_mgmt_ports_on_s6100(self):
'''
During warm-reboot, add back two 10G management ports which got removed from 6100
to ensure no change in bcm.config from older image
'''
if device_info.is_warm_restart_enabled('swss') == False:
log.log_notice("Skip migration on {}, warm-reboot flag not set".format(self.hwsku))
return True

entries = {}
entries['Ethernet64'] = {'alias': 'tenGigE1/1', 'description': 'tenGigE1/1', 'index': '64', 'lanes': '129', 'mtu': '9100', 'pfc_asym': 'off', 'speed': '10000'}
entries['Ethernet65'] = {'alias': 'tenGigE1/2', 'description': 'tenGigE1/2', 'index': '65', 'lanes': '131', 'mtu': '9100', 'pfc_asym': 'off', 'speed': '10000'}
added_ports = 0
for portName in entries.keys():
if self.configDB.get_entry('PORT', portName):
log.log_notice("Skipping migration for port {} - entry exists".format(portName))
continue

log.log_notice("Migrating port {} to configDB for warm-reboot on {}".format(portName, self.hwsku))
self.configDB.set_entry('PORT', portName, entries[portName])

#Copy port to APPL_DB
key = 'PORT_TABLE:' + portName
for field, value in entries[portName].items():
self.appDB.set(self.appDB.APPL_DB, key, field, value)
self.appDB.set(self.appDB.APPL_DB, key, 'admin_status', 'down')
log.log_notice("Copied port {} to appdb".format(key))
added_ports += 1

#Update port count in APPL_DB
portCount = self.appDB.get(self.appDB.APPL_DB, 'PORT_TABLE:PortConfigDone', 'count')
if portCount != '':
total_count = int(portCount) + added_ports
self.appDB.set(self.appDB.APPL_DB, 'PORT_TABLE:PortConfigDone', 'count', str(total_count))
log.log_notice("Port count updated from {} to : {}".format(portCount, self.appDB.get(self.appDB.APPL_DB, 'PORT_TABLE:PortConfigDone', 'count')))
return True

def migrate_intf_table(self):
'''
Migrate all data from existing INTF table in APP DB during warmboot with IP Prefix
Expand Down Expand Up @@ -666,6 +704,10 @@ def common_migration_ops(self):
self.configDB.set_entry(init_cfg_table, key, new_cfg)

self.migrate_copp_table()
if self.asic_type == "broadcom" and 'Force10-S6100' in self.hwsku:
self.migrate_mgmt_ports_on_s6100()
else:
log.log_notice("Asic Type: {}, Hwsku: {}".format(self.asic_type, self.hwsku))

def migrate(self):
version = self.get_version()
Expand Down

0 comments on commit d440df7

Please sign in to comment.