Skip to content

Commit 136aa2b

Browse files
abdosimssonicbld
authored andcommitted
[chassisd]: Updated the API get_platform_info() to return running/detected ASIC's count (sonic-net#16539)
previously, get_num_asics() returns the maximum number of asics. however, the asic_count should be actual number of asics populated which can be get from get_asic_presence_list(). ADO: 25158825 Signed-off-by: Abhishek Dosi <[email protected]>
1 parent 2992658 commit 136aa2b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/sonic-py-common/sonic_py_common/device_info.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,18 @@ def get_platform_info(config_db=None):
366366
if hw_info_dict:
367367
return hw_info_dict
368368

369-
from .multi_asic import get_num_asics
369+
from .multi_asic import get_asic_presence_list
370370

371371
version_info = get_sonic_version_info()
372372

373373
hw_info_dict['platform'] = get_platform()
374374
hw_info_dict['hwsku'] = get_hwsku()
375375
if version_info:
376376
hw_info_dict['asic_type'] = version_info.get('asic_type')
377-
hw_info_dict['asic_count'] = get_num_asics()
377+
try:
378+
hw_info_dict['asic_count'] = len(get_asic_presence_list())
379+
except:
380+
hw_info_dict['asic_count'] = 'N/A'
378381

379382
try:
380383
# TODO: enforce caller to provide config_db explicitly and remove its default value

src/sonic-py-common/sonic_py_common/multi_asic.py

+3
Original file line numberDiff line numberDiff line change
@@ -484,4 +484,7 @@ def get_asic_presence_list():
484484
for asic in asics_presence_list:
485485
# asic is asid id: asic0, asic1.... asicN. Get the numeric value.
486486
asics_list.append(int(get_asic_id_from_name(asic)))
487+
else:
488+
# This is not multi-asic, all asics should be present.
489+
asics_list = list(range(0, get_num_asics()))
487490
return asics_list

0 commit comments

Comments
 (0)