mirror of
https://github.com/Telecominfraproject/oopt-sonic-build.git
synced 2025-10-29 17:22:26 +00:00
[device/celestica]: Update Component APIs (#3510)
* [platform/cel]: add bios upgrade tool * [device/celestica]: update Seastone/E1031 component api to support BIOS upgrade * [device/celestica]: add error handler for eeprom api * [device/celestica]: add component description
This commit is contained in:
committed by
Joe LeVeque
parent
59febed528
commit
ecdd866713
@@ -31,10 +31,10 @@ NUM_FAN = 1
|
|||||||
NUM_PSU = 2
|
NUM_PSU = 2
|
||||||
NUM_THERMAL = 7
|
NUM_THERMAL = 7
|
||||||
NUM_SFP = 52
|
NUM_SFP = 52
|
||||||
|
NUM_COMPONENT = 3
|
||||||
RESET_REGISTER = "0x112"
|
RESET_REGISTER = "0x112"
|
||||||
HOST_REBOOT_CAUSE_PATH = "/host/reboot-cause/previous-reboot-cause.txt"
|
HOST_REBOOT_CAUSE_PATH = "/host/reboot-cause/previous-reboot-cause.txt"
|
||||||
PMON_REBOOT_CAUSE_PATH = "/usr/share/sonic/platform/api_files/reboot-cause/previous-reboot-cause.txt"
|
PMON_REBOOT_CAUSE_PATH = "/usr/share/sonic/platform/api_files/reboot-cause/previous-reboot-cause.txt"
|
||||||
COMPONENT_NAME_LIST = ["SMC_CPLD", "MMC_CPLD", "BIOS"]
|
|
||||||
HOST_CHK_CMD = "docker > /dev/null 2>&1"
|
HOST_CHK_CMD = "docker > /dev/null 2>&1"
|
||||||
|
|
||||||
|
|
||||||
@@ -56,10 +56,13 @@ class Chassis(ChassisBase):
|
|||||||
for index in range(0, NUM_SFP):
|
for index in range(0, NUM_SFP):
|
||||||
sfp = Sfp(index)
|
sfp = Sfp(index)
|
||||||
self._sfp_list.append(sfp)
|
self._sfp_list.append(sfp)
|
||||||
|
for index in range(0, NUM_COMPONENT):
|
||||||
|
component = Component(index)
|
||||||
|
self._component_list.append(component)
|
||||||
ChassisBase.__init__(self)
|
ChassisBase.__init__(self)
|
||||||
self._reboot_cause_path = HOST_REBOOT_CAUSE_PATH if self.__is_host(
|
self._reboot_cause_path = HOST_REBOOT_CAUSE_PATH if self.__is_host(
|
||||||
) else PMON_REBOOT_CAUSE_PATH
|
) else PMON_REBOOT_CAUSE_PATH
|
||||||
self._component_name_list = COMPONENT_NAME_LIST
|
|
||||||
self._watchdog = Watchdog()
|
self._watchdog = Watchdog()
|
||||||
self._eeprom = Tlv()
|
self._eeprom = Tlv()
|
||||||
|
|
||||||
@@ -102,36 +105,6 @@ class Chassis(ChassisBase):
|
|||||||
"""
|
"""
|
||||||
return self._eeprom.get_eeprom()
|
return self._eeprom.get_eeprom()
|
||||||
|
|
||||||
def get_firmware_version(self, component_name):
|
|
||||||
"""
|
|
||||||
Retrieves platform-specific hardware/firmware versions for chassis
|
|
||||||
componenets such as BIOS, CPLD, FPGA, etc.
|
|
||||||
Args:
|
|
||||||
type: A string, component name
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
A string containing platform-specific component versions
|
|
||||||
"""
|
|
||||||
self.component = Component(component_name)
|
|
||||||
if component_name not in self._component_name_list:
|
|
||||||
return None
|
|
||||||
return self.component.get_firmware_version()
|
|
||||||
|
|
||||||
def install_component_firmware(self, component_name, image_path):
|
|
||||||
"""
|
|
||||||
Install firmware to module
|
|
||||||
Args:
|
|
||||||
type: A string, component name.
|
|
||||||
image_path: A string, path to firmware image.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
A boolean, True if install successfully, False if not
|
|
||||||
"""
|
|
||||||
self.component = Component(component_name)
|
|
||||||
if component_name not in self._component_name_list:
|
|
||||||
return False
|
|
||||||
return self.component.upgrade_firmware(image_path)
|
|
||||||
|
|
||||||
def get_reboot_cause(self):
|
def get_reboot_cause(self):
|
||||||
"""
|
"""
|
||||||
Retrieves the cause of the previous reboot
|
Retrieves the cause of the previous reboot
|
||||||
@@ -143,10 +116,9 @@ class Chassis(ChassisBase):
|
|||||||
is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used
|
is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used
|
||||||
to pass a description of the reboot cause.
|
to pass a description of the reboot cause.
|
||||||
"""
|
"""
|
||||||
self.component = Component("SMC_CPLD")
|
|
||||||
description = 'None'
|
description = 'None'
|
||||||
reboot_cause = self.REBOOT_CAUSE_HARDWARE_OTHER
|
reboot_cause = self.REBOOT_CAUSE_HARDWARE_OTHER
|
||||||
hw_reboot_cause = self.component.get_register_value(RESET_REGISTER)
|
hw_reboot_cause = self._component_list[0].get_register_value(RESET_REGISTER)
|
||||||
sw_reboot_cause = self.__read_txt_file(
|
sw_reboot_cause = self.__read_txt_file(
|
||||||
self._reboot_cause_path) or "Unknown"
|
self._reboot_cause_path) or "Unknown"
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import shlex
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from sonic_platform_base.device_base import DeviceBase
|
from sonic_platform_base.component_base import ComponentBase
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
raise ImportError(str(e) + "- required module not found")
|
raise ImportError(str(e) + "- required module not found")
|
||||||
|
|
||||||
@@ -24,16 +24,20 @@ BIOS_VERSION_PATH = "/sys/class/dmi/id/bios_version"
|
|||||||
CONFIG_DB_PATH = "/etc/sonic/config_db.json"
|
CONFIG_DB_PATH = "/etc/sonic/config_db.json"
|
||||||
SMC_CPLD_PATH = "/sys/devices/platform/e1031.smc/version"
|
SMC_CPLD_PATH = "/sys/devices/platform/e1031.smc/version"
|
||||||
GETREG_PATH = "/sys/devices/platform/e1031.smc/getreg"
|
GETREG_PATH = "/sys/devices/platform/e1031.smc/getreg"
|
||||||
|
COMPONENT_NAME_LIST = ["SMC_CPLD", "MMC_CPLD", "BIOS"]
|
||||||
|
COMPONENT_DES_LIST = ["System Management Controller",
|
||||||
|
"Module Management CPLD", "Basic Input/Output System"]
|
||||||
|
|
||||||
|
|
||||||
class Component(DeviceBase):
|
class Component(ComponentBase):
|
||||||
"""Platform-specific Component class"""
|
"""Platform-specific Component class"""
|
||||||
|
|
||||||
DEVICE_TYPE = "component"
|
DEVICE_TYPE = "component"
|
||||||
|
|
||||||
def __init__(self, component_name):
|
def __init__(self, component_index):
|
||||||
DeviceBase.__init__(self)
|
ComponentBase.__init__(self)
|
||||||
self.name = component_name.upper()
|
self.index = component_index
|
||||||
|
self.name = self.get_name()
|
||||||
|
|
||||||
def __run_command(self, command):
|
def __run_command(self, command):
|
||||||
# Run bash command and print output to stdout
|
# Run bash command and print output to stdout
|
||||||
@@ -86,6 +90,22 @@ class Component(DeviceBase):
|
|||||||
cpld_version["MMC_CPLD"] = mmc_cpld_version
|
cpld_version["MMC_CPLD"] = mmc_cpld_version
|
||||||
return cpld_version
|
return cpld_version
|
||||||
|
|
||||||
|
def get_name(self):
|
||||||
|
"""
|
||||||
|
Retrieves the name of the component
|
||||||
|
Returns:
|
||||||
|
A string containing the name of the component
|
||||||
|
"""
|
||||||
|
return COMPONENT_NAME_LIST[self.index]
|
||||||
|
|
||||||
|
def get_description(self):
|
||||||
|
"""
|
||||||
|
Retrieves the description of the component
|
||||||
|
Returns:
|
||||||
|
A string containing the description of the component
|
||||||
|
"""
|
||||||
|
return COMPONENT_DES_LIST[self.index]
|
||||||
|
|
||||||
def get_firmware_version(self):
|
def get_firmware_version(self):
|
||||||
"""
|
"""
|
||||||
Retrieves the firmware version of module
|
Retrieves the firmware version of module
|
||||||
@@ -102,7 +122,7 @@ class Component(DeviceBase):
|
|||||||
|
|
||||||
return fw_version
|
return fw_version
|
||||||
|
|
||||||
def upgrade_firmware(self, image_path):
|
def install_firmware(self, image_path):
|
||||||
"""
|
"""
|
||||||
Install firmware to module
|
Install firmware to module
|
||||||
Args:
|
Args:
|
||||||
@@ -121,7 +141,6 @@ class Component(DeviceBase):
|
|||||||
shutil.copy(image_path, new_image_path)
|
shutil.copy(image_path, new_image_path)
|
||||||
install_command = "ispvm %s" % new_image_path
|
install_command = "ispvm %s" % new_image_path
|
||||||
elif self.name == "BIOS":
|
elif self.name == "BIOS":
|
||||||
print("Not supported")
|
install_command = "afulnx_64 %s /p /b /n /x /r" % image_path
|
||||||
return False
|
|
||||||
|
|
||||||
return self.__run_command(install_command)
|
return self.__run_command(install_command)
|
||||||
|
|||||||
@@ -57,17 +57,15 @@ class Tlv(eeprom_tlvinfo.TlvInfoDecoder):
|
|||||||
def _load_eeprom(self):
|
def _load_eeprom(self):
|
||||||
original_stdout = sys.stdout
|
original_stdout = sys.stdout
|
||||||
sys.stdout = StringIO()
|
sys.stdout = StringIO()
|
||||||
err = self.read_eeprom_db()
|
try:
|
||||||
if err:
|
self.read_eeprom_db()
|
||||||
# Failed to read EEPROM information from database. Read from cache file
|
except:
|
||||||
pass
|
|
||||||
else:
|
|
||||||
decode_output = sys.stdout.getvalue()
|
decode_output = sys.stdout.getvalue()
|
||||||
sys.stdout = original_stdout
|
sys.stdout = original_stdout
|
||||||
return self.__parse_output(decode_output)
|
return self.__parse_output(decode_output)
|
||||||
|
|
||||||
status = self.check_status()
|
status = self.check_status()
|
||||||
if status <> 'ok':
|
if 'ok' not in status:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not os.path.exists(CACHE_ROOT):
|
if not os.path.exists(CACHE_ROOT):
|
||||||
|
|||||||
@@ -31,12 +31,12 @@ NUM_FAN = 2
|
|||||||
NUM_PSU = 2
|
NUM_PSU = 2
|
||||||
NUM_THERMAL = 5
|
NUM_THERMAL = 5
|
||||||
NUM_SFP = 32
|
NUM_SFP = 32
|
||||||
|
NUM_COMPONENT = 5
|
||||||
RESET_REGISTER = "0x103"
|
RESET_REGISTER = "0x103"
|
||||||
HOST_REBOOT_CAUSE_PATH = "/host/reboot-cause/"
|
HOST_REBOOT_CAUSE_PATH = "/host/reboot-cause/"
|
||||||
PMON_REBOOT_CAUSE_PATH = "/usr/share/sonic/platform/api_files/reboot-cause/"
|
PMON_REBOOT_CAUSE_PATH = "/usr/share/sonic/platform/api_files/reboot-cause/"
|
||||||
REBOOT_CAUSE_FILE = "reboot-cause.txt"
|
REBOOT_CAUSE_FILE = "reboot-cause.txt"
|
||||||
PREV_REBOOT_CAUSE_FILE = "previous-reboot-cause.txt"
|
PREV_REBOOT_CAUSE_FILE = "previous-reboot-cause.txt"
|
||||||
COMPONENT_NAME_LIST = ["CPLD1", "CPLD2", "CPLD3", "CPLD4", "BIOS"]
|
|
||||||
HOST_CHK_CMD = "docker > /dev/null 2>&1"
|
HOST_CHK_CMD = "docker > /dev/null 2>&1"
|
||||||
|
|
||||||
|
|
||||||
@@ -58,9 +58,11 @@ class Chassis(ChassisBase):
|
|||||||
for index in range(0, NUM_SFP):
|
for index in range(0, NUM_SFP):
|
||||||
sfp = Sfp(index)
|
sfp = Sfp(index)
|
||||||
self._sfp_list.append(sfp)
|
self._sfp_list.append(sfp)
|
||||||
|
for index in range(0, NUM_COMPONENT):
|
||||||
|
component = Component(index)
|
||||||
|
self._component_list.append(component)
|
||||||
ChassisBase.__init__(self)
|
ChassisBase.__init__(self)
|
||||||
|
|
||||||
self._component_name_list = COMPONENT_NAME_LIST
|
|
||||||
self._watchdog = Watchdog()
|
self._watchdog = Watchdog()
|
||||||
self._eeprom = Tlv()
|
self._eeprom = Tlv()
|
||||||
|
|
||||||
@@ -103,36 +105,6 @@ class Chassis(ChassisBase):
|
|||||||
"""
|
"""
|
||||||
return self._eeprom.get_eeprom()
|
return self._eeprom.get_eeprom()
|
||||||
|
|
||||||
def get_firmware_version(self, component_name):
|
|
||||||
"""
|
|
||||||
Retrieves platform-specific hardware/firmware versions for chassis
|
|
||||||
componenets such as BIOS, CPLD, FPGA, etc.
|
|
||||||
Args:
|
|
||||||
type: A string, component name
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
A string containing platform-specific component versions
|
|
||||||
"""
|
|
||||||
self.component = Component(component_name)
|
|
||||||
if component_name not in self._component_name_list:
|
|
||||||
return None
|
|
||||||
return self.component.get_firmware_version()
|
|
||||||
|
|
||||||
def install_component_firmware(self, component_name, image_path):
|
|
||||||
"""
|
|
||||||
Install firmware to module
|
|
||||||
Args:
|
|
||||||
type: A string, component name.
|
|
||||||
image_path: A string, path to firmware image.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
A boolean, True if install successfully, False if not
|
|
||||||
"""
|
|
||||||
self.component = Component(component_name)
|
|
||||||
if component_name not in self._component_name_list:
|
|
||||||
return False
|
|
||||||
return self.component.upgrade_firmware(image_path)
|
|
||||||
|
|
||||||
def get_reboot_cause(self):
|
def get_reboot_cause(self):
|
||||||
"""
|
"""
|
||||||
Retrieves the cause of the previous reboot
|
Retrieves the cause of the previous reboot
|
||||||
@@ -144,7 +116,6 @@ class Chassis(ChassisBase):
|
|||||||
is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used
|
is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used
|
||||||
to pass a description of the reboot cause.
|
to pass a description of the reboot cause.
|
||||||
"""
|
"""
|
||||||
self.component = Component("CPLD1")
|
|
||||||
description = 'None'
|
description = 'None'
|
||||||
reboot_cause = self.REBOOT_CAUSE_HARDWARE_OTHER
|
reboot_cause = self.REBOOT_CAUSE_HARDWARE_OTHER
|
||||||
|
|
||||||
@@ -153,7 +124,7 @@ class Chassis(ChassisBase):
|
|||||||
prev_reboot_cause_path = (HOST_REBOOT_CAUSE_PATH + PREV_REBOOT_CAUSE_FILE) if self.__is_host(
|
prev_reboot_cause_path = (HOST_REBOOT_CAUSE_PATH + PREV_REBOOT_CAUSE_FILE) if self.__is_host(
|
||||||
) else PMON_REBOOT_CAUSE_PATH + PREV_REBOOT_CAUSE_FILE
|
) else PMON_REBOOT_CAUSE_PATH + PREV_REBOOT_CAUSE_FILE
|
||||||
|
|
||||||
hw_reboot_cause = self.component.get_register_value(RESET_REGISTER)
|
hw_reboot_cause = self._component_list[0].get_register_value(RESET_REGISTER)
|
||||||
|
|
||||||
sw_reboot_cause = self.__read_txt_file(
|
sw_reboot_cause = self.__read_txt_file(
|
||||||
reboot_cause_path) or "Unknown"
|
reboot_cause_path) or "Unknown"
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import shlex
|
|||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from sonic_platform_base.device_base import DeviceBase
|
from sonic_platform_base.component_base import ComponentBase
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
raise ImportError(str(e) + "- required module not found")
|
raise ImportError(str(e) + "- required module not found")
|
||||||
|
|
||||||
@@ -28,16 +28,19 @@ CPLD_ADDR_MAPPING = {
|
|||||||
}
|
}
|
||||||
GETREG_PATH = "/sys/devices/platform/dx010_cpld/getreg"
|
GETREG_PATH = "/sys/devices/platform/dx010_cpld/getreg"
|
||||||
BIOS_VERSION_PATH = "/sys/class/dmi/id/bios_version"
|
BIOS_VERSION_PATH = "/sys/class/dmi/id/bios_version"
|
||||||
|
COMPONENT_NAME_LIST = ["CPLD1", "CPLD2", "CPLD3", "CPLD4", "BIOS"]
|
||||||
|
COMPONENT_DES_LIST = ["CPLD1", "CPLD2", "CPLD3", "CPLD4", "Basic Input/Output System"]
|
||||||
|
|
||||||
|
|
||||||
class Component(DeviceBase):
|
class Component(ComponentBase):
|
||||||
"""Platform-specific Component class"""
|
"""Platform-specific Component class"""
|
||||||
|
|
||||||
DEVICE_TYPE = "component"
|
DEVICE_TYPE = "component"
|
||||||
|
|
||||||
def __init__(self, component_name):
|
def __init__(self, component_index):
|
||||||
DeviceBase.__init__(self)
|
ComponentBase.__init__(self)
|
||||||
self.name = component_name.upper()
|
self.index = component_index
|
||||||
|
self.name = self.get_name()
|
||||||
|
|
||||||
def __run_command(self, command):
|
def __run_command(self, command):
|
||||||
# Run bash command and print output to stdout
|
# Run bash command and print output to stdout
|
||||||
@@ -88,6 +91,22 @@ class Component(DeviceBase):
|
|||||||
cpld_version[cpld_name] = 'None'
|
cpld_version[cpld_name] = 'None'
|
||||||
return cpld_version
|
return cpld_version
|
||||||
|
|
||||||
|
def get_name(self):
|
||||||
|
"""
|
||||||
|
Retrieves the name of the component
|
||||||
|
Returns:
|
||||||
|
A string containing the name of the component
|
||||||
|
"""
|
||||||
|
return COMPONENT_NAME_LIST[self.index]
|
||||||
|
|
||||||
|
def get_description(self):
|
||||||
|
"""
|
||||||
|
Retrieves the description of the component
|
||||||
|
Returns:
|
||||||
|
A string containing the description of the component
|
||||||
|
"""
|
||||||
|
return COMPONENT_DES_LIST[self.index]
|
||||||
|
|
||||||
def get_firmware_version(self):
|
def get_firmware_version(self):
|
||||||
"""
|
"""
|
||||||
Retrieves the firmware version of module
|
Retrieves the firmware version of module
|
||||||
@@ -104,7 +123,7 @@ class Component(DeviceBase):
|
|||||||
|
|
||||||
return fw_version
|
return fw_version
|
||||||
|
|
||||||
def upgrade_firmware(self, image_path):
|
def install_firmware(self, image_path):
|
||||||
"""
|
"""
|
||||||
Install firmware to module
|
Install firmware to module
|
||||||
Args:
|
Args:
|
||||||
@@ -123,7 +142,6 @@ class Component(DeviceBase):
|
|||||||
shutil.copy(image_path, new_image_path)
|
shutil.copy(image_path, new_image_path)
|
||||||
install_command = "ispvm %s" % new_image_path
|
install_command = "ispvm %s" % new_image_path
|
||||||
elif self.name == "BIOS":
|
elif self.name == "BIOS":
|
||||||
print("Not supported")
|
install_command = "afulnx_64 %s /p /b /n /x /r" % image_path
|
||||||
return False
|
|
||||||
|
|
||||||
return self.__run_command(install_command)
|
return self.__run_command(install_command)
|
||||||
|
|||||||
@@ -57,17 +57,15 @@ class Tlv(eeprom_tlvinfo.TlvInfoDecoder):
|
|||||||
def _load_eeprom(self):
|
def _load_eeprom(self):
|
||||||
original_stdout = sys.stdout
|
original_stdout = sys.stdout
|
||||||
sys.stdout = StringIO()
|
sys.stdout = StringIO()
|
||||||
err = self.read_eeprom_db()
|
try:
|
||||||
if err:
|
self.read_eeprom_db()
|
||||||
# Failed to read EEPROM information from database. Read from cache file
|
except:
|
||||||
pass
|
|
||||||
else:
|
|
||||||
decode_output = sys.stdout.getvalue()
|
decode_output = sys.stdout.getvalue()
|
||||||
sys.stdout = original_stdout
|
sys.stdout = original_stdout
|
||||||
return self.__parse_output(decode_output)
|
return self.__parse_output(decode_output)
|
||||||
|
|
||||||
status = self.check_status()
|
status = self.check_status()
|
||||||
if status <> 'ok':
|
if 'ok' not in status:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not os.path.exists(CACHE_ROOT):
|
if not os.path.exists(CACHE_ROOT):
|
||||||
|
|||||||
@@ -3,3 +3,4 @@ dx010/cfg/dx010-modules.conf etc/modules-load.d
|
|||||||
dx010/systemd/platform-modules-dx010.service lib/systemd/system
|
dx010/systemd/platform-modules-dx010.service lib/systemd/system
|
||||||
dx010/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-cel_seastone-r0
|
dx010/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-cel_seastone-r0
|
||||||
services/platform_api/platform_api_mgnt.sh usr/local/bin
|
services/platform_api/platform_api_mgnt.sh usr/local/bin
|
||||||
|
tools/afulnx_64 usr/local/bin
|
||||||
|
|||||||
@@ -5,3 +5,4 @@ services/fancontrol/fancontrol.service lib/systemd/system
|
|||||||
services/fancontrol/fancontrol usr/local/bin
|
services/fancontrol/fancontrol usr/local/bin
|
||||||
haliburton/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-cel_e1031-r0
|
haliburton/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-cel_e1031-r0
|
||||||
services/platform_api/platform_api_mgnt.sh usr/local/bin
|
services/platform_api/platform_api_mgnt.sh usr/local/bin
|
||||||
|
tools/afulnx_64 usr/local/bin
|
||||||
|
|||||||
BIN
platform/broadcom/sonic-platform-modules-cel/tools/afulnx_64
Executable file
BIN
platform/broadcom/sonic-platform-modules-cel/tools/afulnx_64
Executable file
Binary file not shown.
Reference in New Issue
Block a user