Modified SKU based utils to Platform based utils (#4786)
Co-authored-by: Madhan Babu <madhan@arc-build-server.mtr.labs.mlnx>
This commit is contained in:
parent
68576bc2f9
commit
2c830f4074
@ -33,15 +33,15 @@ SYSTEM_NOT_READY = 'system_not_ready'
|
|||||||
SYSTEM_READY = 'system_become_ready'
|
SYSTEM_READY = 'system_become_ready'
|
||||||
SYSTEM_FAIL = 'system_fail'
|
SYSTEM_FAIL = 'system_fail'
|
||||||
|
|
||||||
GET_HWSKU_CMD = "sonic-cfggen -d -v DEVICE_METADATA.localhost.hwsku"
|
GET_PLATFORM_CMD = "sonic-cfggen -d -v DEVICE_METADATA.localhost.platform"
|
||||||
|
|
||||||
# Ethernet<n> <=> sfp<n+SFP_PORT_NAME_OFFSET>
|
# Ethernet<n> <=> sfp<n+SFP_PORT_NAME_OFFSET>
|
||||||
SFP_PORT_NAME_OFFSET = 1
|
SFP_PORT_NAME_OFFSET = 1
|
||||||
SFP_PORT_NAME_CONVENTION = "sfp{}"
|
SFP_PORT_NAME_CONVENTION = "sfp{}"
|
||||||
|
|
||||||
# magic code defnition for port number, qsfp port position of each hwsku
|
# magic code defnition for port number, qsfp port position of each platform
|
||||||
# port_position_tuple = (PORT_START, QSFP_PORT_START, PORT_END, PORT_IN_BLOCK, EEPROM_OFFSET)
|
# port_position_tuple = (PORT_START, QSFP_PORT_START, PORT_END, PORT_IN_BLOCK, EEPROM_OFFSET)
|
||||||
hwsku_dict = {'ACS-MSN2700': 0, 'Mellanox-SN2700': 0, 'Mellanox-SN2700-D48C8': 0, 'LS-SN2700':0, 'ACS-MSN2740': 0, 'ACS-MSN2100': 1, 'ACS-MSN2410': 2, 'ACS-MSN2010': 3, 'ACS-MSN3700': 0, 'ACS-MSN3700C': 0, 'ACS-MSN3800': 4, 'Mellanox-SN3800-D112C8': 4, 'ACS-MSN4700': 0, 'ACS-MSN3420': 5, 'ACS-MSN4600C': 4}
|
platform_dict = {'x86_64-mlnx_msn2700-r0': 0, 'x86_64-mlnx_msn2740-r0': 0, 'x86_64-mlnx_msn2100-r0': 1, 'x86_64-mlnx_msn2410-r0': 2, 'x86_64-mlnx_msn2010-r0': 3, 'x86_64-mlnx_msn3420-r0':5, 'x86_64-mlnx_msn3700-r0': 0, 'x86_64-mlnx_msn3700c-r0': 0, 'x86_64-mlnx_msn3800-r0': 4, 'x86_64-mlnx_msn4600c':4, 'x86_64-mlnx_msn4700-r0': 0}
|
||||||
port_position_tuple_list = [(0, 0, 31, 32, 1), (0, 0, 15, 16, 1), (0, 48, 55, 56, 1), (0, 18, 21, 22, 1), (0, 0, 63, 64, 1), (0, 48, 59, 60, 1)]
|
port_position_tuple_list = [(0, 0, 31, 32, 1), (0, 0, 15, 16, 1), (0, 48, 55, 56, 1), (0, 18, 21, 22, 1), (0, 0, 63, 64, 1), (0, 48, 59, 60, 1)]
|
||||||
|
|
||||||
def log_info(msg, also_print_to_console=False):
|
def log_info(msg, also_print_to_console=False):
|
||||||
@ -86,14 +86,14 @@ class SfpUtil(SfpUtilBase):
|
|||||||
print "dependency on sysfs has been removed"
|
print "dependency on sysfs has been removed"
|
||||||
raise Exception()
|
raise Exception()
|
||||||
|
|
||||||
def get_port_position_tuple_by_sku_name(self):
|
def get_port_position_tuple_by_platform_name(self):
|
||||||
p = subprocess.Popen(GET_HWSKU_CMD, shell=True, stdout=subprocess.PIPE)
|
p = subprocess.Popen(GET_PLATFORM_CMD, shell=True, stdout=subprocess.PIPE)
|
||||||
out, err = p.communicate()
|
out, err = p.communicate()
|
||||||
position_tuple = port_position_tuple_list[hwsku_dict[out.rstrip('\n')]]
|
position_tuple = port_position_tuple_list[platform_dict[out.rstrip('\n')]]
|
||||||
return position_tuple
|
return position_tuple
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
port_position_tuple = self.get_port_position_tuple_by_sku_name()
|
port_position_tuple = self.get_port_position_tuple_by_platform_name()
|
||||||
self.PORT_START = port_position_tuple[0]
|
self.PORT_START = port_position_tuple[0]
|
||||||
self.QSFP_PORT_START = port_position_tuple[1]
|
self.QSFP_PORT_START = port_position_tuple[1]
|
||||||
self.PORT_END = port_position_tuple[2]
|
self.PORT_END = port_position_tuple[2]
|
||||||
|
@ -48,9 +48,9 @@ REBOOT_CAUSE_FILE_LENGTH = 1
|
|||||||
# Global logger class instance
|
# Global logger class instance
|
||||||
logger = Logger()
|
logger = Logger()
|
||||||
|
|
||||||
# magic code defnition for port number, qsfp port position of each hwsku
|
# magic code defnition for port number, qsfp port position of each Platform
|
||||||
# port_position_tuple = (PORT_START, QSFP_PORT_START, PORT_END, PORT_IN_BLOCK, EEPROM_OFFSET)
|
# port_position_tuple = (PORT_START, QSFP_PORT_START, PORT_END, PORT_IN_BLOCK, EEPROM_OFFSET)
|
||||||
hwsku_dict_port = {'ACS-MSN2010': 3, 'ACS-MSN2100': 1, 'ACS-MSN2410': 2, 'ACS-MSN2700': 0, 'Mellanox-SN2700': 0, 'Mellanox-SN2700-D48C8': 0, 'LS-SN2700':0, 'ACS-MSN2740': 0, 'ACS-MSN3700': 0, 'ACS-MSN3700C': 0, 'ACS-MSN3800': 4, 'Mellanox-SN3800-D112C8': 4, 'ACS-MSN4700': 0, 'ACS-MSN3420': 5, 'ACS-MSN4600C': 4}
|
platform_dict_port = {'x86_64-mlnx_msn2010-r0': 3, 'x86_64-mlnx_msn2100-r0': 1, 'x86_64-mlnx_msn2410-r0': 2, 'x86_64-mlnx_msn2700-r0': 0, 'x86_64-mlnx_lssn2700':0, 'x86_64-mlnx_msn2740-r0': 0, 'x86_64-mlnx_msn3420-r0':5, 'x86_64-mlnx_msn3700-r0': 0, 'x86_64-mlnx_msn3700C-r0': 0, 'x86_64-mlnx_msn3800-r0': 4, 'x86_64-mlnx_msn4600c-r0':4, 'x86_64-mlnx_msn4700-r0': 0}
|
||||||
port_position_tuple_list = [(0, 0, 31, 32, 1), (0, 0, 15, 16, 1), (0, 48, 55, 56, 1), (0, 18, 21, 22, 1), (0, 0, 63, 64, 1), (0, 48, 59, 60, 1)]
|
port_position_tuple_list = [(0, 0, 31, 32, 1), (0, 0, 15, 16, 1), (0, 48, 55, 56, 1), (0, 18, 21, 22, 1), (0, 0, 63, 64, 1), (0, 48, 59, 60, 1)]
|
||||||
|
|
||||||
class Chassis(ChassisBase):
|
class Chassis(ChassisBase):
|
||||||
@ -59,8 +59,9 @@ class Chassis(ChassisBase):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(Chassis, self).__init__()
|
super(Chassis, self).__init__()
|
||||||
|
|
||||||
# Initialize SKU name
|
# Initialize SKU name and Platform name
|
||||||
self.sku_name = self._get_sku_name()
|
self.sku_name = self._get_sku_name()
|
||||||
|
self.platform_name = self._get_platform_name()
|
||||||
|
|
||||||
mi = get_machine_info()
|
mi = get_machine_info()
|
||||||
if mi is not None:
|
if mi is not None:
|
||||||
@ -119,7 +120,7 @@ class Chassis(ChassisBase):
|
|||||||
self.sfp_module = SFP
|
self.sfp_module = SFP
|
||||||
|
|
||||||
# Initialize SFP list
|
# Initialize SFP list
|
||||||
port_position_tuple = self._get_port_position_tuple_by_sku_name()
|
port_position_tuple = self._get_port_position_tuple_by_platform_name()
|
||||||
self.PORT_START = port_position_tuple[0]
|
self.PORT_START = port_position_tuple[0]
|
||||||
self.QSFP_PORT_START = port_position_tuple[1]
|
self.QSFP_PORT_START = port_position_tuple[1]
|
||||||
self.PORT_END = port_position_tuple[2]
|
self.PORT_END = port_position_tuple[2]
|
||||||
@ -138,7 +139,7 @@ class Chassis(ChassisBase):
|
|||||||
def initialize_thermals(self):
|
def initialize_thermals(self):
|
||||||
from sonic_platform.thermal import initialize_thermals
|
from sonic_platform.thermal import initialize_thermals
|
||||||
# Initialize thermals
|
# Initialize thermals
|
||||||
initialize_thermals(self.sku_name, self._thermal_list, self._psu_list)
|
initialize_thermals(self.platform_name, self._thermal_list, self._psu_list)
|
||||||
|
|
||||||
|
|
||||||
def initialize_eeprom(self):
|
def initialize_eeprom(self):
|
||||||
@ -249,9 +250,8 @@ class Chassis(ChassisBase):
|
|||||||
out, err = p.communicate()
|
out, err = p.communicate()
|
||||||
return out.rstrip('\n')
|
return out.rstrip('\n')
|
||||||
|
|
||||||
|
def _get_port_position_tuple_by_platform_name(self):
|
||||||
def _get_port_position_tuple_by_sku_name(self):
|
position_tuple = port_position_tuple_list[platform_dict_port[self.platform_name]]
|
||||||
position_tuple = port_position_tuple_list[hwsku_dict_port[self.sku_name]]
|
|
||||||
return position_tuple
|
return position_tuple
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ CONFIG_PATH = "/var/run/hw-management/config"
|
|||||||
FAN_DIR = "/var/run/hw-management/system/fan_dir"
|
FAN_DIR = "/var/run/hw-management/system/fan_dir"
|
||||||
COOLING_STATE_PATH = "/var/run/hw-management/thermal/cooling_cur_state"
|
COOLING_STATE_PATH = "/var/run/hw-management/thermal/cooling_cur_state"
|
||||||
|
|
||||||
|
|
||||||
class Fan(FanBase):
|
class Fan(FanBase):
|
||||||
"""Platform-specific Fan class"""
|
"""Platform-specific Fan class"""
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ PSU_POWER = "power"
|
|||||||
# in most platforms the file psuX_curr, psuX_volt and psuX_power contain current, voltage and power data respectively.
|
# in most platforms the file psuX_curr, psuX_volt and psuX_power contain current, voltage and power data respectively.
|
||||||
# but there are exceptions which will be handled by the following dictionary
|
# but there are exceptions which will be handled by the following dictionary
|
||||||
|
|
||||||
platform_dict_psu = {'x86_64-mlnx_msn3700-r0': 1, 'x86_64-mlnx_msn3700c-r0': 1, 'x86_64-mlnx_msn3800-r0': 1, 'x86_64-mlnx_msn4700-r0': 1}
|
platform_dict_psu = {'x86_64-mlnx_msn3420-r0':1, 'x86_64-mlnx_msn3700-r0': 1, 'x86_64-mlnx_msn3700c-r0': 1, 'x86_64-mlnx_msn3800-r0': 1, 'x86_64-mlnx_msn4600c-r0':1, 'x86_64-mlnx_msn4700-r0': 1}
|
||||||
|
|
||||||
psu_profile_list = [
|
psu_profile_list = [
|
||||||
# default filename convention
|
# default filename convention
|
||||||
@ -40,7 +40,7 @@ psu_profile_list = [
|
|||||||
PSU_VOLTAGE : "power/psu{}_volt",
|
PSU_VOLTAGE : "power/psu{}_volt",
|
||||||
PSU_POWER : "power/psu{}_power"
|
PSU_POWER : "power/psu{}_power"
|
||||||
},
|
},
|
||||||
# for 3420, 3700, 3700c, 3800, 4700
|
# for 3420, 3700, 3700c, 3800, 4600c, 4700
|
||||||
{
|
{
|
||||||
PSU_CURRENT : "power/psu{}_curr",
|
PSU_CURRENT : "power/psu{}_curr",
|
||||||
PSU_VOLTAGE : "power/psu{}_volt_out2",
|
PSU_VOLTAGE : "power/psu{}_volt_out2",
|
||||||
|
@ -124,7 +124,7 @@ thermal_api_names = [
|
|||||||
THERMAL_API_GET_HIGH_THRESHOLD
|
THERMAL_API_GET_HIGH_THRESHOLD
|
||||||
]
|
]
|
||||||
|
|
||||||
hwsku_dict_thermal = {'ACS-MSN2700': 0, 'LS-SN2700':0, 'ACS-MSN2740': 3, 'ACS-MSN2100': 1, 'ACS-MSN2410': 2, 'ACS-MSN2010': 4, 'ACS-MSN3700': 5, 'ACS-MSN3700C': 6, 'Mellanox-SN2700': 0, 'Mellanox-SN2700-D48C8': 0, 'ACS-MSN3800': 7, 'Mellanox-SN3800-D112C8': 7, 'ACS-MSN4700': 8, 'ACS-MSN3420': 9, 'ACS-MSN4600C': 10}
|
platform_dict_thermal = {'x86_64-mlnx_msn2700-r0': 0, 'x86_64-mlnx_lssn2700-r0':0, 'x86_64-mlnx_msn2740-r0': 3, 'x86_64-mlnx_msn2100-r0': 1, 'x86_64-mlnx_msn2410-r0': 2, 'x86_64-mlnx_msn2010-r0': 4, 'x86_64-mlnx_msn3420-r0':9, 'x86_64-mlnx_msn3700-r0': 5, 'x86_64-mlnx_msn3700c-r0': 6, 'x86_64-mlnx_msn3800-r0': 7, 'x86_64-mlnx_msn4600c-r0':9, 'x86_64-mlnx_msn4700-r0': 8}
|
||||||
thermal_profile_list = [
|
thermal_profile_list = [
|
||||||
# 2700
|
# 2700
|
||||||
{
|
{
|
||||||
@ -300,9 +300,9 @@ thermal_profile_list = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def initialize_thermals(sku, thermal_list, psu_list):
|
def initialize_thermals(platform, thermal_list, psu_list):
|
||||||
# create thermal objects for all categories of sensors
|
# create thermal objects for all categories of sensors
|
||||||
tp_index = hwsku_dict_thermal[sku]
|
tp_index = platform_dict_thermal[platform]
|
||||||
thermal_profile = thermal_profile_list[tp_index]
|
thermal_profile = thermal_profile_list[tp_index]
|
||||||
Thermal.thermal_profile = thermal_profile
|
Thermal.thermal_profile = thermal_profile
|
||||||
for category in thermal_device_categories_all:
|
for category in thermal_device_categories_all:
|
||||||
|
Loading…
Reference in New Issue
Block a user