[sonic_py_common][device info] APIs to return chassis type (voq or packet) (#9227)

This commit is contained in:
Mahesh Maddikayala 2021-11-15 09:19:44 -08:00 committed by GitHub
parent ca3a034e6f
commit 2680491c03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -210,6 +210,7 @@ def get_path_to_platform_dir():
return platform_path
def get_path_to_hwsku_dir():
"""
Retreives the path to the device's hardware SKU data directory
@ -228,6 +229,7 @@ def get_path_to_hwsku_dir():
return hwsku_path
def get_paths_to_platform_and_hwsku_dirs():
"""
Retreives the paths to the device's platform and hardware SKU data
@ -249,6 +251,7 @@ def get_paths_to_platform_and_hwsku_dirs():
return (platform_path, hwsku_path)
def get_path_to_port_config_file(hwsku=None, asic=None):
"""
Retrieves the path to the device's port configuration file
@ -351,6 +354,17 @@ def get_platform_info():
hw_info_dict['asic_type'] = version_info['asic_type']
hw_info_dict['asic_count'] = get_num_asics()
try:
config_db = ConfigDBConnector()
config_db.connect()
metadata = config_db.get_table('DEVICE_METADATA')["localhost"]
switch_type = metadata.get('switch_type')
if switch_type:
hw_info_dict['switch_type'] = switch_type
except Exception:
pass
return hw_info_dict
@ -398,6 +412,20 @@ def is_multi_npu():
return (num_npus > 1)
def is_voq_chassis():
switch_type = get_platform_info().get('switch_type')
return True if switch_type and switch_type == 'voq' else False
def is_packet_chassis():
switch_type = get_platform_info().get('switch_type')
return True if switch_type and switch_type == 'chassis-packet' else False
def is_chassis():
return is_voq_chassis() or is_packet_chassis()
def is_supervisor():
platform_env_conf_file_path = get_platform_env_conf_file_path()
if platform_env_conf_file_path is None:
@ -550,6 +578,7 @@ def get_system_routing_stack():
return result
# Check if System warm reboot or Container warm restart is enabled.
def is_warm_restart_enabled(container_name):
state_db = SonicV2Connector(host='127.0.0.1')
@ -571,6 +600,7 @@ def is_warm_restart_enabled(container_name):
state_db.close(state_db.STATE_DB)
return wr_enable_state
# Check if System fast reboot is enabled.
def is_fast_reboot_enabled():
fb_system_state = 0