From 40c4884d2800b8e7192d30a2e6858c0d8cf06d6e Mon Sep 17 00:00:00 2001 From: Sangita Maity Date: Thu, 11 Jun 2020 16:17:06 -0700 Subject: [PATCH] [sfputil] Add support of platform.json (#767) Signed-off-by: Sangita Maity > This PR is dependent on [sonic-platform-common/pull/72](https://github.com/Azure/sonic-platform-common/pull/72) All three PRs are necessary to run `show interfaces transceiver` command. 1. [Azure/sonic-buildimage#3912](https://github.com/Azure/sonic-buildimage/pull/3912) 2. [Azure/sonic-platform-common#72](https://github.com/Azure/sonic-platform-common/pull/72) 3. [Azure/sonic-utilities#767](https://github.com/Azure/sonic-utilities/pull/767) **- What I did** Add support of platform.json in sfputil to get correct output of `show interfaces transceiver` **- How to verify it** Check whether all the below-mentioned CLI's are working correctly. ``` Usage: show interfaces transceiver [OPTIONS] COMMAND [ARGS]... Show SFP Transceiver information Options: -?, -h, --help Show this message and exit. Commands: eeprom Show interface transceiver EEPROM information lpmode Show interface transceiver low-power mode status presence Show interface transceiver presence ``` --- sfputil/main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sfputil/main.py b/sfputil/main.py index abfadae94e..c70c4486b1 100644 --- a/sfputil/main.py +++ b/sfputil/main.py @@ -30,7 +30,8 @@ # Global platform-specific sfputil class instance platform_sfputil = None - +PLATFORM_JSON = 'platform.json' +PORT_CONFIG_INI = 'port_config.ini' # ========================== Syslog wrappers ========================== @@ -325,14 +326,13 @@ def get_path_to_port_config_file(): hwsku_path = "/".join([platform_path, hwsku]) # First check for the presence of the new 'port_config.ini' file - port_config_file_path = "/".join([hwsku_path, "port_config.ini"]) + port_config_file_path = "/".join([platform_path, PLATFORM_JSON]) if not os.path.isfile(port_config_file_path): - # port_config.ini doesn't exist. Try loading the legacy 'portmap.ini' file - port_config_file_path = "/".join([hwsku_path, "portmap.ini"]) + # platform.json doesn't exist. Try loading the legacy 'port_config.ini' file + port_config_file_path = "/".join([hwsku_path, PORT_CONFIG_INI]) return port_config_file_path - # Loads platform specific sfputil module from source def load_platform_sfputil(): global platform_sfputil