-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
193 additions
and
0 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
91 changes: 91 additions & 0 deletions
91
platform/marvell/sonic-platform-db98cx8540-16cd/db98cx8540/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,91 @@ | ||
######################################################################## | ||
# | ||
# 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 sys | ||
import subprocess | ||
from sonic_platform_base.component_base import ComponentBase | ||
except ImportError as e: | ||
raise ImportError(str(e) + "- required module not found") | ||
|
||
if sys.version_info[0] < 3: | ||
import commands as cmd | ||
else: | ||
import subprocess as cmd | ||
|
||
|
||
class Component(ComponentBase): | ||
"""platform-specific Component class""" | ||
|
||
CHASSIS_COMPONENTS = [ | ||
["BIOS", "BIOS - Basic Input/Output System"], | ||
["ONIE-VERSION", "ONIE - Open Network Install Environment"], | ||
] | ||
|
||
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_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_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: | ||
cmdstatus, bios_version = cmd.getstatusoutput('dmidecode -s bios-version') | ||
return bios_version | ||
|
||
if self.index == 1: | ||
cmdstatus, onie_version = cmd.getstatusoutput('grep ^onie_version /host/machine.conf | cut -f2 -d"="') | ||
return onie_version | ||
|
||
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 | ||
|
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
91 changes: 91 additions & 0 deletions
91
platform/marvell/sonic-platform-db98cx8580-32cd/db98cx8580/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,91 @@ | ||
######################################################################## | ||
# | ||
# 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 sys | ||
import subprocess | ||
from sonic_platform_base.component_base import ComponentBase | ||
except ImportError as e: | ||
raise ImportError(str(e) + "- required module not found") | ||
|
||
if sys.version_info[0] < 3: | ||
import commands as cmd | ||
else: | ||
import subprocess as cmd | ||
|
||
|
||
class Component(ComponentBase): | ||
"""platform-specific Component class""" | ||
|
||
CHASSIS_COMPONENTS = [ | ||
["BIOS", "BIOS - Basic Input/Output System"], | ||
["ONIE-VERSION", "ONIE - Open Network Install Environment"], | ||
] | ||
|
||
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_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_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: | ||
cmdstatus, bios_version = cmd.getstatusoutput('dmidecode -s bios-version') | ||
return bios_version | ||
|
||
if self.index == 1: | ||
cmdstatus, onie_version = cmd.getstatusoutput('grep ^onie_version /host/machine.conf | cut -f2 -d"="') | ||
return onie_version | ||
|
||
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 | ||
|