-
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
2 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
platform/marvell-arm64/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,96 @@ | ||
######################################################################## | ||
# | ||
# 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 sys | ||
import subprocess | ||
import ntpath | ||
from sonic_platform_base.component_base import ComponentBase | ||
except ImportError as e: | ||
raise ImportError(str(e) + "- required module not found") | ||
|
||
smbus_present = 1 | ||
try: | ||
import smbus | ||
except ImportError as e: | ||
smbus_present = 0 | ||
|
||
if sys.version_info[0] < 3: | ||
import commands as cmd | ||
else: | ||
import subprocess as cmd | ||
|
||
|
||
class Component(ComponentBase): | ||
"""platform-specific Component class""" | ||
|
||
CHASSIS_COMPONENTS = [ | ||
["U-Boot", "Performs initialization during booting"], | ||
] | ||
|
||
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, uboot_version = cmd.getstatusoutput('grep --null-data U-Boot /dev/mtd0ro|head -2 | cut -d" " -f2') | ||
return uboot_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 | ||
|
96 changes: 96 additions & 0 deletions
96
platform/marvell-arm64/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,96 @@ | ||
######################################################################## | ||
# | ||
# 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 sys | ||
import subprocess | ||
import ntpath | ||
from sonic_platform_base.component_base import ComponentBase | ||
except ImportError as e: | ||
raise ImportError(str(e) + "- required module not found") | ||
|
||
smbus_present = 1 | ||
try: | ||
import smbus | ||
except ImportError as e: | ||
smbus_present = 0 | ||
|
||
if sys.version_info[0] < 3: | ||
import commands as cmd | ||
else: | ||
import subprocess as cmd | ||
|
||
|
||
class Component(ComponentBase): | ||
"""platform-specific Component class""" | ||
|
||
CHASSIS_COMPONENTS = [ | ||
["U-Boot", "Performs initialization during booting"], | ||
] | ||
|
||
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, uboot_version = cmd.getstatusoutput('grep --null-data U-Boot /dev/mtd0ro|head -2 | cut -d" " -f2') | ||
return uboot_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 | ||
|