Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
79 changes: 72 additions & 7 deletions scripts/db_migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_4_0_1'
self.CURRENT_VERSION = 'version_4_0_2'

self.TABLE_NAME = 'VERSIONS'
self.TABLE_KEY = 'DATABASE'
Expand Down Expand Up @@ -167,7 +167,7 @@ def migrate_mgmt_ports_on_s6100(self):
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 @@ -572,7 +572,7 @@ def migrate_port_qos_map_global(self):
dscp_to_tc_map_table_names = self.configDB.get_keys('DSCP_TO_TC_MAP')
if len(dscp_to_tc_map_table_names) == 0:
return

qos_maps = self.configDB.get_table('PORT_QOS_MAP')
if 'global' not in qos_maps.keys():
# We are unlikely to have more than 1 DSCP_TO_TC_MAP in previous versions
Expand All @@ -596,6 +596,58 @@ def migrate_route_table(self):
route_key = "ROUTE_TABLE:{}".format(route_prefix)
self.appDB.set(self.appDB.APPL_DB, route_key, 'weight','')


def update_edgezone_aggregator_config(self):
"""
Update cable length configuration in ConfigDB for T0 neighbor interfaces
connected to EdgeZone Aggregator devices, while resetting the port values to trigger a buffer change
1. Find T1 cable length - this will be the cable length to the EdgeZone Aggregator device.
2. Find a list of all interfaces connected to an EdgeZone Aggregator device.
3. Update CABLE_LENGTH values for these interfaces with the length found in (1).
4. Reset port values to trigger buffer manager event listener to bring across new buffer changes for specified ports
"""
device_neighbor_metadata = self.configDB.get_table("DEVICE_NEIGHBOR_METADATA")
device_neighbors = self.configDB.get_table("DEVICE_NEIGHBOR")
cable_length = self.configDB.get_table("CABLE_LENGTH")
port_table = self.configDB.get_table("PORT")
edgezone_aggregator_devs = []
edgezone_aggregator_intfs = []
EDGEZONE_AGG_CABLE_LENGTH = "5m"
for k, v in device_neighbor_metadata.items():
if "type" in v:
if v["type"] == "LeafRouter":
T1_device = k
elif v["type"] == "EdgeZoneAggregator":
edgezone_aggregator_devs.append(k)

if len(edgezone_aggregator_devs) == 0:
return

for intf, intf_info in device_neighbors.items():
if intf_info["name"] == T1_device:
T1_intf = intf
elif intf_info["name"] in edgezone_aggregator_devs:
edgezone_aggregator_intfs.append(intf)


if cable_length["AZURE"][T1_intf] is not None:
EDGEZONE_AGG_CABLE_LENGTH = cable_length["AZURE"][T1_intf]

cable_length_table = self.configDB.get_entry("CABLE_LENGTH", "AZURE")

for intf, length in cable_length_table.items():
if intf in edgezone_aggregator_intfs:
cable_length_table[intf] = EDGEZONE_AGG_CABLE_LENGTH

""" Set new cable length values """
self.configDB.set_entry("CABLE_LENGTH", "AZURE", cable_length_table)

for intf, intf_items in port_table.items():
if intf in edgezone_aggregator_intfs:
""" Reset interface values to current value so that buffer manager listener picks up new cable length change """
self.configDB.set_entry("PORT", intf, intf_items)


def version_unknown(self):
"""
version_unknown tracks all SONiC versions that doesn't have a version
Expand Down Expand Up @@ -757,7 +809,7 @@ def version_2_0_1(self):
def version_2_0_2(self):
"""
Version 2_0_2
This is the latest version for 202012 branch
This is the latest version for 202012 branch
"""
log.log_info('Handling version_2_0_2')
self.set_version('version_3_0_0')
Expand Down Expand Up @@ -882,15 +934,28 @@ def version_4_0_0(self):
self.stateDB.set(self.stateDB.STATE_DB, 'FAST_RESTART_ENABLE_TABLE|system', 'enable', enable_state)
self.set_version('version_4_0_1')
return 'version_4_0_1'



def version_4_0_1(self):
"""
Version 4_0_1.
This is the latest version for master branch
"""
log.log_info('Handling version_4_0_1')
# Update cable length data and re-assign interface speed for T0 neighbor interfaces connected to EdgeZone Aggregators
self.update_edgezone_aggregator_config()
self.set_version('version_4_0_2')
return 'version_4_0_2'


def version_4_0_2(self):
"""
Version 4_0_2.
This is the latest version for master branch
"""
log.log_info('Handling version_4_0_2')
return None


def get_version(self):
version = self.configDB.get_entry(self.TABLE_NAME, self.TABLE_KEY)
if version and version[self.TABLE_FIELD]:
Expand Down Expand Up @@ -930,7 +995,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 self.hwsku:
self.migrate_mgmt_ports_on_s6100()
else:
log.log_notice("Asic Type: {}, Hwsku: {}".format(self.asic_type, self.hwsku))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"DEVICE_NEIGHBOR_METADATA|ARISTA01T1": {
"hwsku": "Arista-VM",
"mgmt_addr": "10.64.247.200",
"type": "LeafRouter"
},
"DEVICE_NEIGHBOR_METADATA|ARISTA02T1": {
"hwsku": "Arista-VM",
"mgmt_addr": "10.64.247.200",
"type": "LeafRouter"
},
"DEVICE_NEIGHBOR_METADATA|ARISTA03T1": {
"hwsku": "Arista-VM",
"mgmt_addr": "10.64.247.200",
"type": "EdgeZoneAggregator"
},
"DEVICE_NEIGHBOR_METADATA|ARISTA04T1": {
"hwsku": "Arista-VM",
"mgmt_addr": "10.64.247.200",
"type": "EdgeZoneAggregator"
},
"DEVICE_NEIGHBOR|Ethernet0": {
"name": "ARISTA01T1",
"port": "Ethernet1"
},
"DEVICE_NEIGHBOR|Ethernet4": {
"name": "ARISTA02T1",
"port": "Ethernet1"
},
"DEVICE_NEIGHBOR|Ethernet8": {
"name": "ARISTA03T1",
"port": "Ethernet1"
},
"DEVICE_NEIGHBOR|Ethernet12": {
"name": "ARISTA04T1",
"port": "Ethernet1"
},
"PORT|Ethernet0": {
"admin_status": "up",
"alias": "Ethernet1/1",
"description": "",
"index": "1",
"lanes": "77,78",
"mtu": "9100",
"pfc_asym": "off",
"speed": "100000",
"tpid": "0x8100"
},
"PORT|Ethernet4": {
"admin_status": "up",
"alias": "Ethernet2/1",
"description": "",
"index": "2",
"lanes": "79,80",
"mtu": "9100",
"pfc_asym": "off",
"speed": "100000",
"tpid": "0x8100"
},
"PORT|Ethernet8": {
"admin_status": "up",
"alias": "Ethernet3/1",
"description": "",
"index": "3",
"lanes": "81,82",
"mtu": "9100",
"pfc_asym": "off",
"speed": "100000",
"tpid": "0x8100"
},
"PORT|Ethernet12": {
"admin_status": "up",
"alias": "Ethernet4/1",
"description": "",
"index": "4",
"lanes": "83,84",
"mtu": "9100",
"pfc_asym": "off",
"speed": "100000",
"tpid": "0x8100"
},
"CABLE_LENGTH|AZURE": {
"Ethernet0": "40m",
"Ethernet4": "40m",
"Ethernet8": "5m",
"Ethernet12": "5m"
},
"VERSIONS|DATABASE": {
"VERSION": "version_4_0_0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"DEVICE_NEIGHBOR_METADATA|ARISTA01T1": {
"hwsku": "Arista-VM",
"mgmt_addr": "10.64.247.200",
"type": "LeafRouter"
},
"DEVICE_NEIGHBOR_METADATA|ARISTA02T1": {
"hwsku": "Arista-VM",
"mgmt_addr": "10.64.247.200",
"type": "LeafRouter"
},
"DEVICE_NEIGHBOR_METADATA|ARISTA03T1": {
"hwsku": "Arista-VM",
"mgmt_addr": "10.64.247.200",
"type": "EdgeZoneAggregator"
},
"DEVICE_NEIGHBOR_METADATA|ARISTA04T1": {
"hwsku": "Arista-VM",
"mgmt_addr": "10.64.247.200",
"type": "EdgeZoneAggregator"
},
"DEVICE_NEIGHBOR|Ethernet0": {
"name": "ARISTA01T1",
"port": "Ethernet1"
},
"DEVICE_NEIGHBOR|Ethernet4": {
"name": "ARISTA02T1",
"port": "Ethernet1"
},
"DEVICE_NEIGHBOR|Ethernet8": {
"name": "ARISTA03T1",
"port": "Ethernet1"
},
"DEVICE_NEIGHBOR|Ethernet12": {
"name": "ARISTA04T1",
"port": "Ethernet1"
},
"PORT|Ethernet0": {
"admin_status": "up",
"alias": "Ethernet1/1",
"description": "",
"index": "1",
"lanes": "77,78",
"mtu": "9100",
"pfc_asym": "off",
"speed": "100000",
"tpid": "0x8100"
},
"PORT|Ethernet4": {
"admin_status": "up",
"alias": "Ethernet2/1",
"description": "",
"index": "2",
"lanes": "79,80",
"mtu": "9100",
"pfc_asym": "off",
"speed": "100000",
"tpid": "0x8100"
},
"PORT|Ethernet8": {
"admin_status": "up",
"alias": "Ethernet3/1",
"description": "",
"index": "3",
"lanes": "81,82",
"mtu": "9100",
"pfc_asym": "off",
"speed": "100000",
"tpid": "0x8100"
},
"PORT|Ethernet12": {
"admin_status": "up",
"alias": "Ethernet4/1",
"description": "",
"index": "4",
"lanes": "83,84",
"mtu": "9100",
"pfc_asym": "off",
"speed": "100000",
"tpid": "0x8100"
},
"CABLE_LENGTH|AZURE": {
"Ethernet0": "40m",
"Ethernet4": "40m",
"Ethernet8": "40m",
"Ethernet12": "40m"
},
"VERSIONS|DATABASE": {
"VERSION": "version_4_0_0"
}
}
26 changes: 26 additions & 0 deletions tests/db_migrator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,3 +585,29 @@ def test_migrate_weights_for_nexthops(self):
expected_keys = expected_appl_db.get_all(expected_appl_db.APPL_DB, key)
diff = DeepDiff(resulting_keys, expected_keys, ignore_order=True)
assert not diff


class TestWarmUpgrade_T0_EdgeZoneAggregator(object):
@classmethod
def setup_class(cls):
os.environ['UTILITIES_UNIT_TESTING'] = "2"

@classmethod
def teardown_class(cls):
os.environ['UTILITIES_UNIT_TESTING'] = "0"
dbconnector.dedicated_dbs['CONFIG_DB'] = None

def test_warm_upgrade_t0_edgezone_aggregator(self):
dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'config_db', 'sample-t0-edgezoneagg-config-input')
import db_migrator
dbmgtr = db_migrator.DBMigrator(None)
dbmgtr.hwsku = "vs"
dbmgtr.migrate()
dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'config_db', 'sample-t0-edgezoneagg-config-output')
expected_db = Db()

resulting_table = dbmgtr.configDB.get_table('CABLE_LENGTH')
expected_table = expected_db.cfgdb.get_table('CABLE_LENGTH')

diff = DeepDiff(resulting_table, expected_table, ignore_order=True)
assert not diff