Skip to content

Commit 4eab151

Browse files
jostar-yangJostar Yang
and
Jostar Yang
authored
[AS5835-54X] Support system-health and remove extra code (#8137)
Co-authored-by: Jostar Yang <[email protected]>
1 parent 814865b commit 4eab151

File tree

13 files changed

+454
-429
lines changed

13 files changed

+454
-429
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"skip_ledd": true,
3-
"skip_thermalctld": true
3+
"skip_pcied": true
44
}
55

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__all__ = ['chassis', 'eeprom', 'platform', 'psu', 'sfp', 'thermal', 'fan']
1+
__all__ = [ "platform", "chassis", "sfp", "eeprom", "component", "psu", "thermal", "fan", "fan_drawer" ]
22
from . import platform

device/accton/x86_64-accton_as5835_54x-r0/sonic_platform/chassis.py

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@
2929
REBOOT_CAUSE_FILE = "reboot-cause.txt"
3030
PREV_REBOOT_CAUSE_FILE = "previous-reboot-cause.txt"
3131
HOST_CHK_CMD = "docker > /dev/null 2>&1"
32+
SYSLED_FNODE= "/sys/class/leds/as5835_54x_led::diag/brightness"
33+
34+
SYSLED_MODES = {
35+
"0" : "STATUS_LED_COLOR_OFF",
36+
"1" : "STATUS_LED_COLOR_GREEN",
37+
"2" : "STATUS_LED_COLOR_AMBER",
38+
"5" : "STATUS_LED_COLOR_GREEN_BLINK"
39+
}
3240

3341

3442
class Chassis(ChassisBase):
@@ -57,12 +65,12 @@ def __initialize_sfp(self):
5765
self.sfp_module_initialized = True
5866

5967
def __initialize_fan(self):
60-
from sonic_platform.fan import Fan
61-
for fant_index in range(0, NUM_FAN_TRAY):
62-
for fan_index in range(0, NUM_FAN):
63-
fan = Fan(fant_index, fan_index)
64-
self._fan_list.append(fan)
65-
68+
from sonic_platform.fan_drawer import FanDrawer
69+
for fant_index in range(NUM_FAN_TRAY):
70+
fandrawer = FanDrawer(fant_index)
71+
self._fan_drawer_list.append(fandrawer)
72+
self._fan_list.extend(fandrawer._fan_list)
73+
6674
def __initialize_psu(self):
6775
from sonic_platform.psu import Psu
6876
for index in range(0, NUM_PSU):
@@ -84,7 +92,7 @@ def __initialize_components(self):
8492
for index in range(0, NUM_COMPONENT):
8593
component = Component(index)
8694
self._component_list.append(component)
87-
95+
8896
def __initialize_watchdog(self):
8997
from sonic_platform.watchdog import Watchdog
9098
self._watchdog = Watchdog()
@@ -173,7 +181,7 @@ def get_reboot_cause(self):
173181
is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used
174182
to pass a description of the reboot cause.
175183
"""
176-
184+
177185
reboot_cause_path = (HOST_REBOOT_CAUSE_PATH + REBOOT_CAUSE_FILE)
178186
sw_reboot_cause = self._api_helper.read_txt_file(
179187
reboot_cause_path) or "Unknown"
@@ -212,3 +220,40 @@ def get_sfp(self, index):
212220
sys.stderr.write("SFP index {} out of range (1-{})\n".format(
213221
index, len(self._sfp_list)))
214222
return sfp
223+
224+
def get_position_in_parent(self):
225+
"""
226+
Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position
227+
for some reason, or if the associated value of entPhysicalContainedIn is '0', then the value '-1' is returned
228+
Returns:
229+
integer: The 1-based relative physical position in parent device or -1 if cannot determine the position
230+
"""
231+
return -1
232+
233+
def is_replaceable(self):
234+
"""
235+
Indicate whether this device is replaceable.
236+
Returns:
237+
bool: True if it is replaceable.
238+
"""
239+
return False
240+
241+
242+
def initizalize_system_led(self):
243+
return True
244+
245+
def get_status_led(self):
246+
val = self._api_helper.read_txt_file(SYSLED_FNODE)
247+
return SYSLED_MODES[val] if val in SYSLED_MODES else "UNKNOWN"
248+
249+
def set_status_led(self, color):
250+
mode = None
251+
for key, val in SYSLED_MODES.items():
252+
if val == color:
253+
mode = key
254+
break
255+
if mode is None:
256+
return False
257+
else:
258+
return self._api_helper.write_txt_file(SYSLED_FNODE, mode)
259+

device/accton/x86_64-accton_as5835_54x-r0/sonic_platform/component.py

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def __get_bios_version(self):
6767
with open(BIOS_VERSION_PATH, 'r') as fd:
6868
bios_version = fd.read()
6969
return bios_version.strip()
70-
except Exception as e:
70+
except Exception as e:
7171
print('Get exception when read bios')
7272
return None
7373

@@ -126,3 +126,55 @@ def install_firmware(self, image_path):
126126
A boolean, True if install successfully, False if not
127127
"""
128128
raise NotImplementedError
129+
130+
def get_presence(self):
131+
"""
132+
Retrieves the presence of the device
133+
Returns:
134+
bool: True if device is present, False if not
135+
"""
136+
return True
137+
138+
def get_model(self):
139+
"""
140+
Retrieves the model number (or part number) of the device
141+
Returns:
142+
string: Model/part number of device
143+
"""
144+
return 'N/A'
145+
146+
def get_serial(self):
147+
"""
148+
Retrieves the serial number of the device
149+
Returns:
150+
string: Serial number of device
151+
"""
152+
return 'N/A'
153+
154+
def get_status(self):
155+
"""
156+
Retrieves the operational status of the device
157+
Returns:
158+
A boolean value, True if device is operating properly, False if not
159+
"""
160+
return True
161+
162+
def get_position_in_parent(self):
163+
"""
164+
Retrieves 1-based relative physical position in parent device.
165+
If the agent cannot determine the parent-relative position
166+
for some reason, or if the associated value of
167+
entPhysicalContainedIn is'0', then the value '-1' is returned
168+
Returns:
169+
integer: The 1-based relative physical position in parent device
170+
or -1 if cannot determine the position
171+
"""
172+
return -1
173+
174+
def is_replaceable(self):
175+
"""
176+
Indicate whether this device is replaceable.
177+
Returns:
178+
bool: True if it is replaceable.
179+
"""
180+
return False

device/accton/x86_64-accton_as5835_54x-r0/sonic_platform/eeprom.py.bak

Lines changed: 0 additions & 131 deletions
This file was deleted.

0 commit comments

Comments
 (0)