Skip to content

Commit

Permalink
[sfputil] Add support of platform.json (#767)
Browse files Browse the repository at this point in the history
Signed-off-by: Sangita Maity <[email protected]>

> This PR is dependent on [sonic-platform-common/pull/72](sonic-net/sonic-platform-common#72)

All three PRs are necessary to run `show interfaces transceiver` command.

1. [sonic-net/sonic-buildimage#3912](sonic-net/sonic-buildimage#3912)
2. [sonic-net/sonic-platform-common#72](sonic-net/sonic-platform-common#72)
3. [#767](#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
```
  • Loading branch information
samaity authored Jun 11, 2020
1 parent a6c4456 commit 8affaf7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sfputil/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ==========================

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8affaf7

Please sign in to comment.