From ca4e2ae61f45bdfaf8bd55844cf71baec2c476cc Mon Sep 17 00:00:00 2001 From: Abhishek Dosi Date: Fri, 19 Aug 2022 20:43:34 +0000 Subject: [PATCH] Added new API to return runtime metdata as needed during Feature Table field rendering by hostcfgd. Signed-off-by: Abhishek Dosi --- src/sonic-py-common/sonic_py_common/device_info.py | 12 ++++++++++-- 1 file changed, 10 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 6126dd6dd284..cbb5d8bd38cd 100644 --- a/src/sonic-py-common/sonic_py_common/device_info.py +++ b/src/sonic-py-common/sonic_py_common/device_info.py @@ -432,7 +432,7 @@ def is_multi_npu(): def is_voq_chassis(): switch_type = get_platform_info().get('switch_type') - return True if switch_type and switch_type == 'voq' else False + return True if switch_type and (switch_type == 'voq' or switch_type == 'fabric') else False def is_packet_chassis(): @@ -441,7 +441,7 @@ def is_packet_chassis(): def is_chassis(): - return is_voq_chassis() or is_packet_chassis() + return is_voq_chassis() or is_packet_chassis() or is_supervisor() def is_supervisor(): @@ -459,6 +459,14 @@ def is_supervisor(): return True return False +def get_device_runtime_metadata(): + chassis_metada = {} + if is_chassis(): + chassis_metadata = {'CHASSIS_METADATA': {'module_type' : 'supervisor' if is_supervisor() else 'linecard', + 'chassis_type': 'voq' if is_voq_chassis() else 'packet'}} + + port_metadata = {'ETHERNET_PORTS_PRESENT': True if get_path_to_port_config_file(hwsku=None, asic="0" if is_multi_npu() else None) else False} + return {'DEVICE_RUNTIME_METADATA': chassis_metadata | port_metadata } def get_npu_id_from_name(npu_name): if npu_name.startswith(NPU_NAME_PREFIX):