-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DellEMC : Platform2.0 API Implementation for Component [S6000, S6100,…
… Z9100] (#3588)
- Loading branch information
1 parent
2d87ca4
commit ee4ca2c
Showing
7 changed files
with
495 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
platform/broadcom/sonic-platform-modules-dell/s6000/sonic_platform/component.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
#!/usr/bin/env python | ||
|
||
######################################################################## | ||
# DELLEMC S6000 | ||
# | ||
# Module contains an implementation of SONiC Platform Base API and | ||
# provides the Components' (e.g., BIOS, CPLD, FPGA, etc.) available in | ||
# the platform | ||
# | ||
######################################################################## | ||
|
||
try: | ||
import os | ||
import subprocess | ||
from sonic_platform_base.component_base import ComponentBase | ||
except ImportError as e: | ||
raise ImportError(str(e) + "- required module not found") | ||
|
||
BIOS_QUERY_VERSION_COMMAND = "dmidecode -s system-version" | ||
|
||
|
||
class Component(ComponentBase): | ||
"""DellEMC Platform-specific Component class""" | ||
|
||
CPLD_DIR = "/sys/devices/platform/dell-s6000-cpld.0" | ||
|
||
CHASSIS_COMPONENTS = [ | ||
["BIOS", ("Performs initialization of hardware components during " | ||
"booting")], | ||
["System-CPLD", "Used for managing CPU board devices and power"], | ||
["Master-CPLD", ("Used for managing Fan, PSU, system LEDs, QSFP " | ||
"modules (1-16)")], | ||
["Slave-CPLD", "Used for managing QSFP modules (17-32)"] | ||
] | ||
|
||
def __init__(self, component_index): | ||
self.index = component_index | ||
self.name = self.CHASSIS_COMPONENTS[self.index][0] | ||
self.description = self.CHASSIS_COMPONENTS[self.index][1] | ||
|
||
def _get_cpld_register(self, reg_name): | ||
rv = 'ERR' | ||
mb_reg_file = self.CPLD_DIR+'/'+reg_name | ||
|
||
if (not os.path.isfile(mb_reg_file)): | ||
return rv | ||
|
||
try: | ||
with open(mb_reg_file, 'r') as fd: | ||
rv = fd.read() | ||
except Exception as error: | ||
rv = 'ERR' | ||
|
||
rv = rv.rstrip('\r\n') | ||
rv = rv.lstrip(" ") | ||
return rv | ||
|
||
def _get_command_result(self, cmdline): | ||
try: | ||
proc = subprocess.Popen(cmdline.split(), stdout=subprocess.PIPE, | ||
stderr=subprocess.STDOUT) | ||
stdout = proc.communicate()[0] | ||
proc.wait() | ||
result = stdout.rstrip('\n') | ||
except OSError: | ||
result = None | ||
|
||
return result | ||
|
||
def _get_cpld_version(self, cpld_number): | ||
cpld_version_reg = { | ||
1: "system_cpld_ver", | ||
2: "master_cpld_ver", | ||
3: "slave_cpld_ver" | ||
} | ||
|
||
cpld_version = self._get_cpld_register(cpld_version_reg[cpld_number]) | ||
|
||
if cpld_version != 'ERR': | ||
return str(int(cpld_version, 16)) | ||
else: | ||
return 'NA' | ||
|
||
def get_name(self): | ||
""" | ||
Retrieves the name of the component | ||
Returns: | ||
A string containing the name of the component | ||
""" | ||
return self.name | ||
|
||
def get_description(self): | ||
""" | ||
Retrieves the description of the component | ||
Returns: | ||
A string containing the description of the component | ||
""" | ||
return self.description | ||
|
||
def get_firmware_version(self): | ||
""" | ||
Retrieves the firmware version of the component | ||
Returns: | ||
A string containing the firmware version of the component | ||
""" | ||
if self.index == 0: | ||
bios_ver = self._get_command_result(BIOS_QUERY_VERSION_COMMAND) | ||
|
||
if not bios_ver: | ||
return 'NA' | ||
else: | ||
return bios_ver | ||
|
||
elif self.index <= 3: | ||
return self._get_cpld_version(self.index) | ||
|
||
def install_firmware(self, image_path): | ||
""" | ||
Installs firmware to the component | ||
Args: | ||
image_path: A string, path to firmware image | ||
Returns: | ||
A boolean, True if install was successful, False if not | ||
""" | ||
return False |
Oops, something went wrong.