Skip to content

Commit

Permalink
[sonic-py-common] Add platform.json to port_config files candidates o…
Browse files Browse the repository at this point in the history
…nly if interfaces are present within platform.json (sonic-net#5538)

* [sonic-py-common] add platform.json to port_config

Signed-off-by: vaibhav-dahiya <[email protected]>
  • Loading branch information
vdahiya12 authored and santhosh-kt committed Feb 25, 2021
1 parent 0b4e36d commit d16248e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/sonic-py-common/sonic_py_common/device_info.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import glob
import json
import os
import re
import subprocess
Expand Down Expand Up @@ -255,8 +256,21 @@ def get_path_to_port_config_file(hwsku=None, asic=None):

# if 'hwsku.json' file is available, Check for 'platform.json' file presence,
# if 'platform.json' is available, APPEND it. Otherwise, SKIP it.

"""
This length check for interfaces in platform.json is performed to make sure
the cfggen does not fail if port configuration information is not present
TODO: once platform.json has all the necessary port config information
remove this check
"""

if os.path.isfile(hwsku_json_file):
port_config_candidates.append(os.path.join(platform_path, PLATFORM_JSON_FILE))
if os.path.isfile(os.path.join(platform_path, PLATFORM_JSON_FILE)):
json_file = os.path.join(platform_path, PLATFORM_JSON_FILE)
platform_data = json.loads(open(json_file).read())
interfaces = platform_data.get('interfaces', None)
if interfaces is not None and len(interfaces) > 0:
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 d16248e

Please sign in to comment.