-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Edgecore][as7726/PDDF] Add needed api to sonic_platform #12848
Closed
jostar-yang
wants to merge
1
commit into
sonic-net:master
from
jostar-yang:as7726_20221128_pddf_pytest
+506
−41
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
17 changes: 17 additions & 0 deletions
17
device/accton/x86_64-accton_as7726_32x-r0/system_health_monitoring_config.json
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,17 @@ | ||
{ | ||
"services_to_ignore": [], | ||
"devices_to_ignore": [ | ||
"asic", | ||
"psu.voltage", | ||
"psu.temperature", | ||
"PSU1_FAN1.speed", | ||
"PSU2_FAN1.speed" | ||
], | ||
"user_defined_checkers": [], | ||
"polling_interval": 60, | ||
"led_color": { | ||
"fault": "STATUS_LED_COLOR_AMBER", | ||
"normal": "STATUS_LED_COLOR_GREEN", | ||
"booting": "STATUS_LED_COLOR_OFF" | ||
} | ||
} |
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
190 changes: 190 additions & 0 deletions
190
platform/broadcom/sonic-platform-modules-accton/as7726-32x/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,190 @@ | ||
############################################################################# | ||
# | ||
# Component contains an implementation of SONiC Platform Base API and | ||
# provides the components firmware management function | ||
# | ||
############################################################################# | ||
|
||
try: | ||
import subprocess | ||
from sonic_platform_base.component_base import ComponentBase | ||
except ImportError as e: | ||
raise ImportError(str(e) + "- required module not found") | ||
|
||
CPLD_ADDR_MAPPING = { | ||
"CPLD1": ['11', '0x60'], | ||
"CPLD2": ['12', '0x62'], | ||
"CPLD3": ['13', '0x64'], | ||
"CPLD4": ['54', '0x66'] | ||
} | ||
SYSFS_PATH = "/sys/bus/i2c/devices/" | ||
BIOS_VERSION_PATH = "/sys/class/dmi/id/bios_version" | ||
COMPONENT_LIST= [ | ||
("CPLD1", "CPLD 1"), | ||
("CPLD2", "CPLD 2"), | ||
("CPLD3", "CPLD 3"), | ||
("CPLD4", "CPLD 4"), | ||
("CPLD5", "CPLD 5"), | ||
("BIOS", "Basic Input/Output System") | ||
|
||
] | ||
|
||
class Component(ComponentBase): | ||
"""Platform-specific Component class""" | ||
|
||
DEVICE_TYPE = "component" | ||
|
||
def __init__(self, component_index=0): | ||
self.index = component_index | ||
self.name = self.get_name() | ||
|
||
def __run_command(self, command): | ||
# Run bash command and print output to stdout | ||
try: | ||
process = subprocess.Popen( | ||
shlex.split(command), stdout=subprocess.PIPE) | ||
while True: | ||
output = process.stdout.readline() | ||
if output == '' and process.poll() is not None: | ||
break | ||
rc = process.poll() | ||
if rc != 0: | ||
return False | ||
except Exception: | ||
return False | ||
return True | ||
|
||
def __get_bios_version(self): | ||
# Retrieves the BIOS firmware version | ||
try: | ||
with open(BIOS_VERSION_PATH, 'r') as fd: | ||
bios_version = fd.read() | ||
return bios_version.strip() | ||
except Exception as e: | ||
return None | ||
|
||
def __get_cpld_version(self): | ||
# Retrieves the CPLD firmware version | ||
cpld_version = dict() | ||
for cpld_name in CPLD_ADDR_MAPPING: | ||
cmd = "i2cget -f -y {0} {1} 0x1".format(CPLD_ADDR_MAPPING[cpld_name][0], CPLD_ADDR_MAPPING[cpld_name][1]) | ||
status, value = subprocess.getstatusoutput(cmd) | ||
if not status: | ||
cpld_version_raw = value.rstrip() | ||
cpld_version[cpld_name] = "{}".format(int(cpld_version_raw,16)) | ||
|
||
return cpld_version | ||
|
||
|
||
def __get_cpld_cpu_version(self): | ||
try: | ||
cpu_version = dict() | ||
cmd = "i2cget -f -y 0 0x65 0x01" | ||
status, output1 = subprocess.getstatusoutput(cmd) | ||
if status == 0 : | ||
cpu_version = "{}".format(output1[2:]) | ||
else : | ||
cpu_version = 'None' | ||
except Exception as e: | ||
cpu_version = 'None' | ||
|
||
return cpu_version | ||
|
||
def get_name(self): | ||
""" | ||
Retrieves the name of the component | ||
Returns: | ||
A string containing the name of the component | ||
""" | ||
return COMPONENT_LIST[self.index][0] | ||
|
||
def get_description(self): | ||
""" | ||
Retrieves the description of the component | ||
Returns: | ||
A string containing the description of the component | ||
""" | ||
return COMPONENT_LIST[self.index][1] | ||
|
||
def get_firmware_version(self): | ||
""" | ||
Retrieves the firmware version of module | ||
Returns: | ||
string: The firmware versions of the module | ||
""" | ||
fw_version = None | ||
|
||
if self.name == "BIOS": | ||
fw_version = self.__get_bios_version() | ||
elif "CPLD5" in self.name: | ||
fw_version = self.__get_cpld_cpu_version() | ||
elif "CPLD" in self.name: | ||
cpld_version = self.__get_cpld_version() | ||
fw_version = cpld_version.get(self.name) | ||
|
||
return fw_version | ||
|
||
def install_firmware(self, image_path): | ||
""" | ||
Install firmware to module | ||
Args: | ||
image_path: A string, path to firmware image | ||
Returns: | ||
A boolean, True if install successfully, False if not | ||
""" | ||
raise NotImplementedError | ||
|
||
def get_presence(self): | ||
""" | ||
Retrieves the presence of the device | ||
Returns: | ||
bool: True if device is present, False if not | ||
""" | ||
return True | ||
|
||
def get_model(self): | ||
""" | ||
Retrieves the model number (or part number) of the device | ||
Returns: | ||
string: Model/part number of device | ||
""" | ||
return 'N/A' | ||
|
||
def get_serial(self): | ||
""" | ||
Retrieves the serial number of the device | ||
Returns: | ||
string: Serial number of device | ||
""" | ||
return 'N/A' | ||
|
||
def get_status(self): | ||
""" | ||
Retrieves the operational status of the device | ||
Returns: | ||
A boolean value, True if device is operating properly, False if not | ||
""" | ||
return True | ||
|
||
def get_position_in_parent(self): | ||
""" | ||
Retrieves 1-based relative physical position in parent device. | ||
If the agent cannot determine the parent-relative position | ||
for some reason, or if the associated value of | ||
entPhysicalContainedIn is'0', then the value '-1' is returned | ||
Returns: | ||
integer: The 1-based relative physical position in parent device | ||
or -1 if cannot determine the position | ||
""" | ||
return -1 | ||
|
||
def is_replaceable(self): | ||
""" | ||
Indicate whether this device is replaceable. | ||
Returns: | ||
bool: True if it is replaceable. | ||
""" | ||
return False | ||
|
||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who writes the reboot reason to this file ?
and if the reboot reason is HW_WATCHDOG_TIMEOUT then how it is being detected?