Skip to content
6 changes: 5 additions & 1 deletion generic_config_updater/field_operation_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ def get_asic_name():
hwsku = output.rstrip('\n')
if asic_type == 'mellanox' or asic_type == 'vs':
spc1_hwskus = asic_mapping["mellanox_asics"]["spc1"]
spc3_hwskus = asic_mapping["mellanox_asics"]["spc3"]
if hwsku.lower() in [spc1_hwsku.lower() for spc1_hwsku in spc1_hwskus]:
asic = "spc1"
return asic
if hwsku.lower() in [spc3_hwsku.lower() for spc3_hwsku in spc3_hwskus]:
asic = "spc3"
return asic
if asic_type == 'broadcom' or asic_type == 'vs':
broadcom_asics = asic_mapping["broadcom_asics"]
for asic_shorthand, hwskus in broadcom_asics.items():
Expand Down Expand Up @@ -75,7 +79,7 @@ def _get_fields_in_patch():

if 'value' in patch_element.keys() and isinstance(patch_element['value'], dict):
for key in patch_element['value']:
cleaned_fields.append(cleaned_field+ '/' + key)
cleaned_fields.append(cleaned_field + '/' + key) if len(cleaned_field) > 0 else cleaned_fields.append(key)
Copy link
Copy Markdown
Contributor

@qiluo-msft qiluo-msft Jul 18, 2023

Choose a reason for hiding this comment

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

if

It's better to use if-else block. Single line is too long. #Closed

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.

Changed to if-else block

else:
cleaned_fields.append(cleaned_field)

Expand Down
11 changes: 9 additions & 2 deletions generic_config_updater/gcu_field_operation_validators.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"helper_data": {
"rdma_config_update_validator": {
"mellanox_asics": {
"spc1": [ "ACS-MSN2700", "ACS-MSN2740", "ACS-MSN2100", "ACS-MSN2410", "ACS-MSN2010", "Mellanox-SN2700", "Mellanox-SN2700-D48C8" ]
"spc1": [ "ACS-MSN2700", "ACS-MSN2740", "ACS-MSN2100", "ACS-MSN2410", "ACS-MSN2010", "Mellanox-SN2700", "Mellanox-SN2700-D48C8" ],
"spc3": [ "ACS-MSN4700", "ACS-MSN4600", "ACS-MSN4600C", "ACS-MSN4410", "Mellanox-SN4600C-D112C8", "Mellanox-SN4600C-C64" ]
},
"broadcom_asics": {
"th": [ "Force10-S6100", "Arista-7060CX-32S-C32", "Arista-7060CX-32S-C32-T1", "Arista-7060CX-32S-D48C8", "Celestica-DX010-C32", "Seastone-DX010" ],
Expand All @@ -37,11 +38,13 @@
"restoration_time",
"detection_time",
"action",
"global/poll_interval"
"global/poll_interval",
""
],
"operations": ["remove", "add", "replace"],
"platforms": {
"spc1": "20181100",
"spc3": "20220500",
"td2": "20181100",
"th": "20181100",
"th2": "20181100",
Expand All @@ -65,6 +68,7 @@
"operations": ["replace"],
"platforms": {
"spc1": "20191100",
"spc3": "20220500",
"td2": "",
"th": "20221100",
"th2": "20221100",
Expand All @@ -86,6 +90,7 @@
"operations": ["replace"],
"platforms": {
"spc1": "20181100",
"spc3": "20220500",
"td2": "20181100",
"th": "20181100",
"th2": "20181100",
Expand All @@ -100,6 +105,7 @@
"operations": ["replace"],
"platforms": {
"spc1": "20191100",
"spc3": "20220500",
"td2": "",
"th": "20221100",
"th2": "20221100",
Expand All @@ -123,6 +129,7 @@
"operations": ["replace"],
"platforms": {
"spc1": "20181100",
"spc3": "20220500",
"td2": "20181100",
"th": "20181100",
"th2": "20181100",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ def test_get_asic_spc1(self, mock_popen, mock_get_sonic_version_info):
mock_popen.return_value.communicate.return_value = ["Mellanox-SN2700-D48C8", 0]
self.assertEqual(fov.get_asic_name(), "spc1")

@patch('sonic_py_common.device_info.get_sonic_version_info')
@patch('subprocess.Popen')
def test_get_asic_spc3(self, mock_popen, mock_get_sonic_version_info):
mock_get_sonic_version_info.return_value = {'asic_type': 'mellanox'}
mock_popen.return_value = mock.Mock()
mock_popen.return_value.communicate.return_value = ["Mellanox-SN4600C-C64", 0]
self.assertEqual(fov.get_asic_name(), "spc3")

@patch('sonic_py_common.device_info.get_sonic_version_info')
@patch('subprocess.Popen')
def test_get_asic_th(self, mock_popen, mock_get_sonic_version_info):
Expand Down