Skip to content

Commit

Permalink
kamel: Seastone2 system status LED - PR sonic-net#10824
Browse files Browse the repository at this point in the history
  • Loading branch information
bluecmd committed Feb 19, 2024
1 parent b210582 commit eef4043
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,15 @@
"host_path": "/usr/share/sonic/device/x86_64-cel_seastone_2-r0/sonic_platform_config/event.py",
"pmon_path": "/usr/share/sonic/platform/sonic_platform_config/event.py",
"class": "SfpEvent"
},
"system_led_status": {
"output_source": "sysfs_value",
"set_method": "sysfs_value",
"sysfs_path": "/sys/devices/platform/baseboard/sys_led"
},
"system_led_color": {
"output_source": "sysfs_value",
"set_method": "sysfs_value",
"sysfs_path": "/sys/devices/platform/baseboard/sys_led_color"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"services_to_ignore": [],
"devices_to_ignore": [
"asic",
"psu.temperature",
"fan.speed",
"psu.voltage"
],
"user_defined_checkers": [],
"polling_interval": 60,
"led_color": {
"fault": "orange",
"normal": "green",
"booting": "both_blink"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,65 @@ def get_change_event(self, timeout=0):

return self._api_common.get_event(timeout, self._config['get_change_event'], self._sfp_list)

##############################################
# System LED methods
##############################################

def initizalize_system_led(self):
self.has_system_led = 'system_led_status' in self._config and 'system_led_color' in self._config
return self.has_system_led

def set_status_led(self, color):
"""
Sets the state of the system LED
Args:
color: A string representing the color with which to set the
system LED
Returns:
bool: True if system LED state is set successfully, False if not
"""
if not self.initizalize_system_led():
raise NotImplementedError

led_data = {
'green': ('green', 'on'),
'green_blink': ('green', '4hz'),
'orange': ('yellow', 'on'),
'orange_blink': ('yellow', '4hz'),
'both_blink': ('both', '4hz'),
'off': ('off', 'off')
}.get(color, None)

if not led_data:
return False

return self._api_common.set_output(0, led_data[0], self._config['system_led_color']) and \
self._api_common.set_output(0, led_data[1], self._config['system_led_status'])

def get_status_led(self):
"""
Gets the state of the system LED
Returns:
A string, one of the valid LED color strings which could be vendor
specified.
"""
if not self.initizalize_system_led():
raise NotImplementedError

led_color = self._api_common.get_output(0, self._config['system_led_color'], Common.NULL_VAL)
led_status = self._api_common.get_output(0, self._config['system_led_status'], Common.NULL_VAL)

color_name = {
('green', 'on'): 'green',
('green', '4hz'): 'green_blink',
('yellow', 'on'): 'orange',
('yellow', '4hz'): 'orange_blink',
('both', '4hz'): 'both_blink',
('off', 'off'): 'off'
}.get((led_color, led_status), None)

return color_name

# ##############################################################
# ###################### Other methods ########################
# ##############################################################
Expand Down

0 comments on commit eef4043

Please sign in to comment.