Skip to content

Commit 6f93832

Browse files
abdosimssonicbld
authored andcommitted
[chassisd]: Updated the API get_platform_info() to return running/detected ASIC's count (#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 3ac09d5 commit 6f93832

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
@@ -367,15 +367,18 @@ def get_platform_info(config_db=None):
367367
if hw_info_dict:
368368
return hw_info_dict
369369

370-
from .multi_asic import get_num_asics
370+
from .multi_asic import get_asic_presence_list
371371

372372
version_info = get_sonic_version_info()
373373

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

380383
try:
381384
# 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)