Skip to content

Commit

Permalink
[Mellanox] Allow user to set LED to orange (#9259)
Browse files Browse the repository at this point in the history
Why I did it
Nvidia platform API does not support set LED to orange

How I did it
Allow user to set LED to orange

How to verify it
Added unit test
Manual test
  • Loading branch information
Junchao-Mellanox authored and judyjoseph committed Dec 27, 2021
1 parent ec46a23 commit 2b82af5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions platform/mellanox/mlnx-platform-api/sonic_platform/led.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ def set_status(self, color):
else:
return False

utils.write_file(led_path, Led.LED_ON)
status = True
elif color == Led.STATUS_LED_COLOR_ORANGE:
if Led.STATUS_LED_COLOR_ORANGE in led_cap_list:
led_path = self.get_orange_led_path()
elif Led.STATUS_LED_COLOR_RED in led_cap_list:
led_path = self.get_red_led_path()
else:
return False

utils.write_file(led_path, Led.LED_ON)
status = True
elif color == Led.STATUS_LED_COLOR_OFF:
Expand Down
6 changes: 4 additions & 2 deletions platform/mellanox/mlnx-platform-api/tests/test_led.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def mock_write_file(file_path, content, **kwargs):
assert obj.set_status_led(Led.STATUS_LED_COLOR_GREEN) is True
assert obj.get_status_led() == Led.STATUS_LED_COLOR_GREEN
mock_file_content[physical_led.get_green_led_path()] = Led.LED_OFF
assert obj.set_status_led(Led.STATUS_LED_COLOR_ORANGE) is False
assert obj.set_status_led(Led.STATUS_LED_COLOR_ORANGE) is True
assert obj.get_status_led() == Led.STATUS_LED_COLOR_RED
mock_file_content[physical_led.get_orange_led_path()] = Led.LED_OFF

assert obj.set_status_led(Led.STATUS_LED_COLOR_RED_BLINK)
assert obj.get_status_led() == Led.STATUS_LED_COLOR_RED_BLINK
Expand All @@ -85,7 +87,7 @@ def _mock_led_file_content(self, led):
led.get_green_led_path(): Led.LED_ON,
led.get_red_led_path(): Led.LED_OFF,
led.get_orange_led_path(): Led.LED_OFF,
led.get_led_cap_path(): 'none green green_blink red red_blink',
led.get_led_cap_path(): 'none green green_blink red red_blink orange',
led.get_green_led_delay_off_path(): Led.LED_OFF,
led.get_green_led_delay_on_path(): Led.LED_OFF,
led.get_red_led_delay_off_path(): Led.LED_OFF,
Expand Down

0 comments on commit 2b82af5

Please sign in to comment.