Skip to content

Commit 47f8499

Browse files
authored
[202205][DBMigrator] Update db_migrator to support EdgeZoneAggregator Buffer Config for T0s (sonic-net#2769)
* EZA buffer addition to 202205 branch * moved code change to common migrator * Update sample-t0-edgezoneagg-config-output.json * Update sample-t0-edgezoneagg-config-same-cable-output.json
1 parent ece22b7 commit 47f8499

6 files changed

+582
-9
lines changed

scripts/db_migrator.py

+52-9
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def migrate_mgmt_ports_on_s6100(self):
164164
self.appDB.set(self.appDB.APPL_DB, 'PORT_TABLE:PortConfigDone', 'count', str(total_count))
165165
log.log_notice("Port count updated from {} to : {}".format(portCount, self.appDB.get(self.appDB.APPL_DB, 'PORT_TABLE:PortConfigDone', 'count')))
166166
return True
167-
167+
168168
def migrate_intf_table(self):
169169
'''
170170
Migrate all data from existing INTF table in APP DB during warmboot with IP Prefix
@@ -262,7 +262,6 @@ def migrate_config_db_buffer_tables_for_dynamic_calculation(self, speed_list, ca
262262
@append_item_method - a function which is called to append an item to the list of pending commit items
263263
any update to buffer configuration will be pended and won't be applied until
264264
all configuration is checked and aligns with the default one
265-
266265
1. Buffer profiles for lossless PGs in BUFFER_PROFILE table will be removed
267266
if their names have the convention of pg_lossless_<speed>_<cable_length>_profile
268267
where the speed and cable_length belongs speed_list and cable_len_list respectively
@@ -346,15 +345,13 @@ def prepare_dynamic_buffer_for_warm_reboot(self, buffer_pools=None, buffer_profi
346345
'''
347346
This is the very first warm reboot of buffermgrd (dynamic) if the system reboot from old image by warm-reboot
348347
In this case steps need to be taken to get buffermgrd prepared (for warm reboot)
349-
350348
During warm reboot, buffer tables should be installed in the first place.
351349
However, it isn't able to achieve that when system is warm-rebooted from an old image
352350
without dynamic buffer supported, because the buffer info wasn't in the APPL_DB in the old image.
353351
The solution is to copy that info from CONFIG_DB into APPL_DB in db_migrator.
354352
During warm-reboot, db_migrator adjusts buffer info in CONFIG_DB by removing some fields
355353
according to requirement from dynamic buffer calculation.
356354
The buffer info before that adjustment needs to be copied to APPL_DB.
357-
358355
1. set WARM_RESTART_TABLE|buffermgrd as {restore_count: 0}
359356
2. Copy the following tables from CONFIG_DB into APPL_DB in case of warm reboot
360357
The separator in fields that reference objects in other table needs to be updated from '|' to ':'
@@ -364,7 +361,6 @@ def prepare_dynamic_buffer_for_warm_reboot(self, buffer_pools=None, buffer_profi
364361
- BUFFER_QUEUE, separator updated for field 'profile
365362
- BUFFER_PORT_INGRESS_PROFILE_LIST, separator updated for field 'profile_list'
366363
- BUFFER_PORT_EGRESS_PROFILE_LIST, separator updated for field 'profile_list'
367-
368364
'''
369365
warmreboot_state = self.stateDB.get(self.stateDB.STATE_DB, 'WARM_RESTART_ENABLE_TABLE|system', 'enable')
370366
mmu_size = self.stateDB.get(self.stateDB.STATE_DB, 'BUFFER_MAX_PARAM_TABLE|global', 'mmu_size')
@@ -569,7 +565,7 @@ def migrate_port_qos_map_global(self):
569565
dscp_to_tc_map_table_names = self.configDB.get_keys('DSCP_TO_TC_MAP')
570566
if len(dscp_to_tc_map_table_names) == 0:
571567
return
572-
568+
573569
qos_maps = self.configDB.get_table('PORT_QOS_MAP')
574570
if 'global' not in qos_maps.keys():
575571
# We are unlikely to have more than 1 DSCP_TO_TC_MAP in previous versions
@@ -593,6 +589,50 @@ def migrate_route_table(self):
593589
route_key = "ROUTE_TABLE:{}".format(route_prefix)
594590
self.appDB.set(self.appDB.APPL_DB, route_key, 'weight','')
595591

592+
def update_edgezone_aggregator_config(self):
593+
"""
594+
Update cable length configuration in ConfigDB for T0 neighbor interfaces
595+
connected to EdgeZone Aggregator devices, while resetting the port values to trigger a buffer change
596+
1. Find a list of all interfaces connected to an EdgeZone Aggregator device.
597+
2. If all the cable lengths are the same, do nothing and return.
598+
3. If there are different cable lengths, update CABLE_LENGTH values for these interfaces with a constant value of 40m.
599+
"""
600+
device_neighbor_metadata = self.configDB.get_table("DEVICE_NEIGHBOR_METADATA")
601+
device_neighbors = self.configDB.get_table("DEVICE_NEIGHBOR")
602+
cable_length = self.configDB.get_table("CABLE_LENGTH")
603+
port_table = self.configDB.get_table("PORT")
604+
edgezone_aggregator_devs = []
605+
edgezone_aggregator_intfs = []
606+
EDGEZONE_AGG_CABLE_LENGTH = "40m"
607+
for k, v in device_neighbor_metadata.items():
608+
if v.get("type") == "EdgeZoneAggregator":
609+
edgezone_aggregator_devs.append(k)
610+
611+
if len(edgezone_aggregator_devs) == 0:
612+
return
613+
614+
for intf, intf_info in device_neighbors.items():
615+
if intf_info.get("name") in edgezone_aggregator_devs:
616+
edgezone_aggregator_intfs.append(intf)
617+
618+
cable_length_table = self.configDB.get_entry("CABLE_LENGTH", "AZURE")
619+
first_cable_intf = next(iter(cable_length_table))
620+
first_cable_length = cable_length_table[first_cable_intf]
621+
index = 0
622+
623+
for intf, length in cable_length_table.items():
624+
index += 1
625+
if first_cable_length != length:
626+
break
627+
elif index == len(cable_length_table):
628+
# All cable lengths are the same, nothing to modify
629+
return
630+
631+
for intf, length in cable_length_table.items():
632+
if intf in edgezone_aggregator_intfs:
633+
# Set new cable length values
634+
self.configDB.set(self.configDB.CONFIG_DB, "CABLE_LENGTH|AZURE", intf, EDGEZONE_AGG_CABLE_LENGTH)
635+
596636
def version_unknown(self):
597637
"""
598638
version_unknown tracks all SONiC versions that doesn't have a version
@@ -754,7 +794,7 @@ def version_2_0_1(self):
754794
def version_2_0_2(self):
755795
"""
756796
Version 2_0_2
757-
This is the latest version for 202012 branch
797+
This is the latest version for 202012 branch
758798
"""
759799
log.log_info('Handling version_2_0_2')
760800
self.set_version('version_3_0_0')
@@ -839,7 +879,7 @@ def version_3_0_5(self):
839879
self.stateDB.set(self.stateDB.STATE_DB, 'FAST_RESTART_ENABLE_TABLE|system', 'enable', enable_state)
840880
self.set_version('version_3_0_6')
841881
return 'version_3_0_6'
842-
882+
843883
def version_3_0_6(self):
844884
"""
845885
Current latest version. Nothing to do here.
@@ -882,13 +922,16 @@ def common_migration_ops(self):
882922

883923
if self.asic_type != "mellanox":
884924
self.migrate_copp_table()
885-
if self.asic_type == "broadcom" and 'Force10-S6100' in self.hwsku:
925+
if self.asic_type == "broadcom" and 'Force10-S6100' in self.hwsku:
886926
self.migrate_mgmt_ports_on_s6100()
887927
else:
888928
log.log_notice("Asic Type: {}, Hwsku: {}".format(self.asic_type, self.hwsku))
889929

890930
self.migrate_route_table()
891931

932+
# Updating edgezone aggregator cable length config for T0 devices
933+
self.update_edgezone_aggregator_config()
934+
892935
def migrate(self):
893936
version = self.get_version()
894937
log.log_info('Upgrading from version ' + version)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{
2+
"DEVICE_NEIGHBOR_METADATA|ARISTA01T1": {
3+
"hwsku": "Arista-VM",
4+
"mgmt_addr": "10.64.247.200",
5+
"type": "EdgeZoneAggregator"
6+
},
7+
"DEVICE_NEIGHBOR_METADATA|ARISTA02T1": {
8+
"hwsku": "Arista-VM",
9+
"mgmt_addr": "10.64.247.200",
10+
"type": "EdgeZoneAggregator"
11+
},
12+
"DEVICE_NEIGHBOR_METADATA|ARISTA03T1": {
13+
"hwsku": "Arista-VM",
14+
"mgmt_addr": "10.64.247.200",
15+
"type": "EdgeZoneAggregator"
16+
},
17+
"DEVICE_NEIGHBOR_METADATA|ARISTA04T1": {
18+
"hwsku": "Arista-VM",
19+
"mgmt_addr": "10.64.247.200",
20+
"type": "EdgeZoneAggregator"
21+
},
22+
"DEVICE_NEIGHBOR|Ethernet0": {
23+
"name": "ARISTA01T1",
24+
"port": "Ethernet1"
25+
},
26+
"DEVICE_NEIGHBOR|Ethernet4": {
27+
"name": "ARISTA02T1",
28+
"port": "Ethernet1"
29+
},
30+
"DEVICE_NEIGHBOR|Ethernet8": {
31+
"name": "ARISTA03T1",
32+
"port": "Ethernet1"
33+
},
34+
"DEVICE_NEIGHBOR|Ethernet12": {
35+
"name": "ARISTA04T1",
36+
"port": "Ethernet1"
37+
},
38+
"DEVICE_NEIGHBOR|Ethernet16": {
39+
"name": "Servers1",
40+
"port": "eth0"
41+
},
42+
"DEVICE_NEIGHBOR|Ethernet20": {
43+
"name": "Servers2",
44+
"port": "eth0"
45+
},
46+
"PORT|Ethernet0": {
47+
"admin_status": "up",
48+
"alias": "Ethernet1/1",
49+
"description": "",
50+
"index": "1",
51+
"lanes": "77,78",
52+
"mtu": "9100",
53+
"pfc_asym": "off",
54+
"speed": "100000",
55+
"tpid": "0x8100"
56+
},
57+
"PORT|Ethernet4": {
58+
"admin_status": "up",
59+
"alias": "Ethernet2/1",
60+
"description": "",
61+
"index": "2",
62+
"lanes": "79,80",
63+
"mtu": "9100",
64+
"pfc_asym": "off",
65+
"speed": "100000",
66+
"tpid": "0x8100"
67+
},
68+
"PORT|Ethernet8": {
69+
"admin_status": "up",
70+
"alias": "Ethernet3/1",
71+
"description": "",
72+
"index": "3",
73+
"lanes": "81,82",
74+
"mtu": "9100",
75+
"pfc_asym": "off",
76+
"speed": "100000",
77+
"tpid": "0x8100"
78+
},
79+
"PORT|Ethernet12": {
80+
"admin_status": "up",
81+
"alias": "Ethernet4/1",
82+
"description": "",
83+
"index": "4",
84+
"lanes": "83,84",
85+
"mtu": "9100",
86+
"pfc_asym": "off",
87+
"speed": "100000",
88+
"tpid": "0x8100"
89+
},
90+
"PORT|Ethernet16": {
91+
"admin_status": "up",
92+
"alias": "Ethernet5/1",
93+
"description": "",
94+
"index": "5",
95+
"lanes": "85,86",
96+
"mtu": "9100",
97+
"pfc_asym": "off",
98+
"speed": "100000",
99+
"tpid": "0x8100"
100+
},
101+
"PORT|Ethernet20": {
102+
"admin_status": "up",
103+
"alias": "Ethernet6/1",
104+
"description": "",
105+
"index": "6",
106+
"lanes": "87,88",
107+
"mtu": "9100",
108+
"pfc_asym": "off",
109+
"speed": "100000",
110+
"tpid": "0x8100"
111+
},
112+
"CABLE_LENGTH|AZURE": {
113+
"Ethernet0": "300m",
114+
"Ethernet4": "300m",
115+
"Ethernet8": "300m",
116+
"Ethernet12": "300m",
117+
"Ethernet16": "5m",
118+
"Ethernet20": "5m"
119+
},
120+
"VERSIONS|DATABASE": {
121+
"VERSION": "version_1_0_1"
122+
}
123+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{
2+
"DEVICE_NEIGHBOR_METADATA|ARISTA01T1": {
3+
"hwsku": "Arista-VM",
4+
"mgmt_addr": "10.64.247.200",
5+
"type": "EdgeZoneAggregator"
6+
},
7+
"DEVICE_NEIGHBOR_METADATA|ARISTA02T1": {
8+
"hwsku": "Arista-VM",
9+
"mgmt_addr": "10.64.247.200",
10+
"type": "EdgeZoneAggregator"
11+
},
12+
"DEVICE_NEIGHBOR_METADATA|ARISTA03T1": {
13+
"hwsku": "Arista-VM",
14+
"mgmt_addr": "10.64.247.200",
15+
"type": "EdgeZoneAggregator"
16+
},
17+
"DEVICE_NEIGHBOR_METADATA|ARISTA04T1": {
18+
"hwsku": "Arista-VM",
19+
"mgmt_addr": "10.64.247.200",
20+
"type": "EdgeZoneAggregator"
21+
},
22+
"DEVICE_NEIGHBOR|Ethernet0": {
23+
"name": "ARISTA01T1",
24+
"port": "Ethernet1"
25+
},
26+
"DEVICE_NEIGHBOR|Ethernet4": {
27+
"name": "ARISTA02T1",
28+
"port": "Ethernet1"
29+
},
30+
"DEVICE_NEIGHBOR|Ethernet8": {
31+
"name": "ARISTA03T1",
32+
"port": "Ethernet1"
33+
},
34+
"DEVICE_NEIGHBOR|Ethernet12": {
35+
"name": "ARISTA04T1",
36+
"port": "Ethernet1"
37+
},
38+
"DEVICE_NEIGHBOR|Ethernet16": {
39+
"name": "Servers1",
40+
"port": "eth0"
41+
},
42+
"DEVICE_NEIGHBOR|Ethernet20": {
43+
"name": "Servers2",
44+
"port": "eth0"
45+
},
46+
"PORT|Ethernet0": {
47+
"admin_status": "up",
48+
"alias": "Ethernet1/1",
49+
"description": "",
50+
"index": "1",
51+
"lanes": "77,78",
52+
"mtu": "9100",
53+
"pfc_asym": "off",
54+
"speed": "100000",
55+
"tpid": "0x8100"
56+
},
57+
"PORT|Ethernet4": {
58+
"admin_status": "up",
59+
"alias": "Ethernet2/1",
60+
"description": "",
61+
"index": "2",
62+
"lanes": "79,80",
63+
"mtu": "9100",
64+
"pfc_asym": "off",
65+
"speed": "100000",
66+
"tpid": "0x8100"
67+
},
68+
"PORT|Ethernet8": {
69+
"admin_status": "up",
70+
"alias": "Ethernet3/1",
71+
"description": "",
72+
"index": "3",
73+
"lanes": "81,82",
74+
"mtu": "9100",
75+
"pfc_asym": "off",
76+
"speed": "100000",
77+
"tpid": "0x8100"
78+
},
79+
"PORT|Ethernet12": {
80+
"admin_status": "up",
81+
"alias": "Ethernet4/1",
82+
"description": "",
83+
"index": "4",
84+
"lanes": "83,84",
85+
"mtu": "9100",
86+
"pfc_asym": "off",
87+
"speed": "100000",
88+
"tpid": "0x8100"
89+
},
90+
"PORT|Ethernet16": {
91+
"admin_status": "up",
92+
"alias": "Ethernet5/1",
93+
"description": "",
94+
"index": "5",
95+
"lanes": "85,86",
96+
"mtu": "9100",
97+
"pfc_asym": "off",
98+
"speed": "100000",
99+
"tpid": "0x8100"
100+
},
101+
"PORT|Ethernet20": {
102+
"admin_status": "up",
103+
"alias": "Ethernet6/1",
104+
"description": "",
105+
"index": "6",
106+
"lanes": "87,88",
107+
"mtu": "9100",
108+
"pfc_asym": "off",
109+
"speed": "100000",
110+
"tpid": "0x8100"
111+
},
112+
"CABLE_LENGTH|AZURE": {
113+
"Ethernet0": "40m",
114+
"Ethernet4": "40m",
115+
"Ethernet8": "40m",
116+
"Ethernet12": "40m",
117+
"Ethernet16": "5m",
118+
"Ethernet20": "5m"
119+
},
120+
"VERSIONS|DATABASE": {
121+
"VERSION": "version_3_0_6"
122+
}
123+
}

0 commit comments

Comments
 (0)