Skip to content

Commit

Permalink
Add get_dpu_list()
Browse files Browse the repository at this point in the history
  • Loading branch information
vvolam committed Nov 7, 2024
1 parent 116d40c commit 14287b5
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/sonic-py-common/sonic_py_common/device_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,9 +950,9 @@ def get_dpu_info():
# Retrieve platform.json data
platform_data = get_platform_json_data()
if platform_data:
# Convert to lower case avoid case sensitive.
# Convert keys to lower case to avoid case sensitivity.
data = {k.lower(): v for k, v in platform_data.items()}
dpu_info = data.get('dpus', None)
dpu_info = data.get('dpus', {})
return dpu_info

return {}
Expand All @@ -962,8 +962,6 @@ def get_num_dpus():
"""
Retrieves the number of DPUs from platform.json file.
Args:
Returns:
A integer to indicate the number of DPUs.
"""
Expand All @@ -973,3 +971,18 @@ def get_num_dpus():
return len(dpu_info)

return 0


def get_dpu_list():
"""
Retrieves the list of DPUs from platform.json file.
Returns:
A list indicating the list of DPUs.
"""

dpu_info = get_dpu_info()
if dpu_info is not None and len(dpu_info) > 0:
return list(dpu_info)

return []

0 comments on commit 14287b5

Please sign in to comment.