Skip to content

Commit

Permalink
[portconfig] Fallback to port_config.ini if hwsku.json is not availab…
Browse files Browse the repository at this point in the history
…le (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 <sangitamaity0211@gmail.com>
  • Loading branch information
samaity authored and santhosh-kt committed Feb 25, 2021
1 parent edf36b9 commit 51d645a
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/sonic-py-common/sonic_py_common/device_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
PORT_CONFIG_FILE = "port_config.ini"
PLATFORM_JSON_FILE = "platform.json"

# HwSKU configuration file name
HWSKU_JSON_FILE = 'hwsku.json'

# Multi-NPU constants
# TODO: Move Multi-ASIC-related functions and constants to a "multi_asic.py" module
NPU_NAME_PREFIX = "asic"
Expand Down Expand Up @@ -247,8 +250,13 @@ def get_path_to_port_config_file(hwsku=None, asic=None):

port_config_candidates = []

# Check for 'platform.json' file presence first
port_config_candidates.append(os.path.join(platform_path, PLATFORM_JSON_FILE))
# Check for 'hwsku.json' file presence first
hwsku_json_file = os.path.join(hwsku_path, HWSKU_JSON_FILE)

# if 'hwsku.json' file is available, Check for 'platform.json' file presence,
# if 'platform.json' is available, APPEND it. Otherwise, SKIP it.
if os.path.isfile(hwsku_json_file):
port_config_candidates.append(os.path.join(platform_path, PLATFORM_JSON_FILE))

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

0 comments on commit 51d645a

Please sign in to comment.