Skip to content

Commit 51d645a

Browse files
samaitysanthosh-kt
authored andcommitted
[portconfig] Fallback to port_config.ini if hwsku.json is not available (sonic-net#5434)
**- Why I did it** As discussed, This PR covers the below points. 1. Give precedence to platform.json only if both platform.json and hwsku.json file exist. In case only platform.json exists, we don’t allow breakout for that HWSKU and fallback to port_config.ini. **- How I did it** check for `hwsku.json` file presence under get_path_to_port_config_file function. Signed-off-by: Sangita Maity <[email protected]>
1 parent edf36b9 commit 51d645a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/sonic-py-common/sonic_py_common/device_info.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
PORT_CONFIG_FILE = "port_config.ini"
2121
PLATFORM_JSON_FILE = "platform.json"
2222

23+
# HwSKU configuration file name
24+
HWSKU_JSON_FILE = 'hwsku.json'
25+
2326
# Multi-NPU constants
2427
# TODO: Move Multi-ASIC-related functions and constants to a "multi_asic.py" module
2528
NPU_NAME_PREFIX = "asic"
@@ -247,8 +250,13 @@ def get_path_to_port_config_file(hwsku=None, asic=None):
247250

248251
port_config_candidates = []
249252

250-
# Check for 'platform.json' file presence first
251-
port_config_candidates.append(os.path.join(platform_path, PLATFORM_JSON_FILE))
253+
# Check for 'hwsku.json' file presence first
254+
hwsku_json_file = os.path.join(hwsku_path, HWSKU_JSON_FILE)
255+
256+
# if 'hwsku.json' file is available, Check for 'platform.json' file presence,
257+
# if 'platform.json' is available, APPEND it. Otherwise, SKIP it.
258+
if os.path.isfile(hwsku_json_file):
259+
port_config_candidates.append(os.path.join(platform_path, PLATFORM_JSON_FILE))
252260

253261
# Check for 'port_config.ini' file presence in a few locations
254262
if asic:

0 commit comments

Comments
 (0)