Skip to content

Commit

Permalink
Merge pull request sonic-net#2 from samaity/sfputil_platform_Compatib…
Browse files Browse the repository at this point in the history
…ility

[sfputil] Add support of platform.json
  • Loading branch information
zhenggen-xu authored Nov 21, 2019
2 parents c12c443 + 841edbc commit 27ce188
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions sfputil/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@

# Global platform-specific sfputil class instance
platform_sfputil = None

PLATFORM_JSON = 'platform.json'
PORT_CONFIG_INI = 'portconfig.ini'
PORTMAP_INI = 'portmap.ini'

# ========================== Syslog wrappers ==========================

Expand Down Expand Up @@ -329,14 +331,16 @@ 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([hwsku_path, PLATFORM_JSON])
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 = "/".join([hwsku_path, PORT_CONFIG_INI])
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"])
port_config_file_path = "/".join([hwsku_path, PORTMAP_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 27ce188

Please sign in to comment.