[Mellanox] PSU led platform API fixes (#6213)
Return 'False' when unsupported led color is requested, preventing an exception. Signed-off-by: Shlomi Bitton <shlomibi@nvidia.com>
This commit is contained in:
parent
9d35fa19dc
commit
feb4b04cdc
@ -286,9 +286,11 @@ class SharedLed(object):
|
||||
def update_status_led(self):
|
||||
target_color = Led.STATUS_LED_COLOR_GREEN
|
||||
for virtual_led in self._virtual_leds:
|
||||
if SharedLed.LED_PRIORITY[virtual_led.get_led_color()] < SharedLed.LED_PRIORITY[target_color]:
|
||||
target_color = virtual_led.get_led_color()
|
||||
|
||||
try:
|
||||
if SharedLed.LED_PRIORITY[virtual_led.get_led_color()] < SharedLed.LED_PRIORITY[target_color]:
|
||||
target_color = virtual_led.get_led_color()
|
||||
except KeyError:
|
||||
return False
|
||||
return self._led.set_status(target_color)
|
||||
|
||||
def get_status(self):
|
||||
@ -302,8 +304,13 @@ class ComponentFaultyIndicator(object):
|
||||
self._shared_led.add_virtual_leds(self)
|
||||
|
||||
def set_status(self, color):
|
||||
current_color = self._color
|
||||
self._color = color
|
||||
return self._shared_led.update_status_led()
|
||||
if self._shared_led.update_status_led():
|
||||
return True
|
||||
else:
|
||||
self._color = current_color
|
||||
return False
|
||||
|
||||
def get_led_color(self):
|
||||
return self._color
|
||||
|
Reference in New Issue
Block a user