-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[sonic-utilities][sonic-py-common] Move logic to get port config file path to sonic-py-common and update sonic-utilities to comply #5264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
c7a9f2f
9bf9aed
9b0ae79
ab2f8a3
d9c7acc
bd27d97
9841702
1a1c126
1b67ff8
e131ead
e18a0c7
e1d34d8
38a0bb8
2607b9f
db4149e
de5fda7
8988996
8047e8a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -181,27 +181,31 @@ def get_paths_to_platform_and_hwsku_dirs(): | |
|
|
||
| return (platform_path, hwsku_path) | ||
|
|
||
|
|
||
| def get_path_to_port_config_file(): | ||
| def get_path_to_port_config_file(asic=None): | ||
| """ | ||
| Retrieves the path to the device's port configuration file | ||
jleveque marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Returns: | ||
| A string containing the path the the device's port configuration file | ||
| """ | ||
| # Get platform and hwsku path | ||
| (platform_path, hwsku_path) = get_paths_to_platform_and_hwsku_dirs() | ||
|
|
||
| # First check for the presence of the new 'platform.json' file | ||
| port_config_file_path = os.path.join(platform_path, PLATFORM_JSON_FILE) | ||
| if not os.path.isfile(port_config_file_path): | ||
| # platform.json doesn't exist. Try loading the legacy 'port_config.ini' file | ||
| port_config_file_path = os.path.join(hwsku_path, PORT_CONFIG_FILE) | ||
| if not os.path.isfile(port_config_file_path): | ||
| raise OSError("Failed to detect port config file: {}".format(port_config_file_path)) | ||
| port_config_candidates = [] | ||
|
|
||
| # Check for 'platform.json' file presence first | ||
| port_config_candidates.append(os.path.join(platform_path, PLATFORM_JSON)) | ||
|
|
||
| return port_config_file_path | ||
| # Check for 'port_config.ini' file presence in a few locations | ||
| port_config_candidates.append(os.path.join(hwsku_path, PORT_CONFIG_INI)) | ||
| if asic: | ||
| port_config_candidates.append(os.path.join(hwsku_path, asic, PORT_CONFIG_INI)) | ||
| port_config_candidates.append(os.path.join(platform_path, PORT_CONFIG_INI)) | ||
|
||
|
|
||
| for candidate in port_config_candidates: | ||
| if os.path.isfile(candidate): | ||
| return candidate | ||
|
|
||
| return None | ||
|
|
||
| def get_sonic_version_info(): | ||
| if not os.path.isfile(SONIC_VERSION_YAML_PATH): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.