From 9a63b9df8d783c2ebe8983584c1ba409847695e1 Mon Sep 17 00:00:00 2001 From: abdosi <58047199+abdosi@users.noreply.github.com> Date: Fri, 29 Sep 2023 09:15:28 -0700 Subject: [PATCH] [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 --- src/sonic-py-common/sonic_py_common/device_info.py | 7 +++++-- src/sonic-py-common/sonic_py_common/multi_asic.py | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/sonic-py-common/sonic_py_common/device_info.py b/src/sonic-py-common/sonic_py_common/device_info.py index 77284b48dbc5..a2dedb5a2ec7 100644 --- a/src/sonic-py-common/sonic_py_common/device_info.py +++ b/src/sonic-py-common/sonic_py_common/device_info.py @@ -366,7 +366,7 @@ def get_platform_info(config_db=None): if hw_info_dict: return hw_info_dict - from .multi_asic import get_num_asics + from .multi_asic import get_asic_presence_list version_info = get_sonic_version_info() @@ -374,7 +374,10 @@ def get_platform_info(config_db=None): hw_info_dict['hwsku'] = get_hwsku() if version_info: hw_info_dict['asic_type'] = version_info.get('asic_type') - hw_info_dict['asic_count'] = get_num_asics() + try: + hw_info_dict['asic_count'] = len(get_asic_presence_list()) + except: + hw_info_dict['asic_count'] = 'N/A' try: # TODO: enforce caller to provide config_db explicitly and remove its default value diff --git a/src/sonic-py-common/sonic_py_common/multi_asic.py b/src/sonic-py-common/sonic_py_common/multi_asic.py index 423a9036337b..1873e6f682d7 100644 --- a/src/sonic-py-common/sonic_py_common/multi_asic.py +++ b/src/sonic-py-common/sonic_py_common/multi_asic.py @@ -484,4 +484,7 @@ def get_asic_presence_list(): for asic in asics_presence_list: # asic is asid id: asic0, asic1.... asicN. Get the numeric value. asics_list.append(int(get_asic_id_from_name(asic))) + else: + # This is not multi-asic, all asics should be present. + asics_list = list(range(0, get_num_asics())) return asics_list