Skip to content
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

[Mellanox] Allow user to set LED to orange #9259

Merged
merged 1 commit into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not Led.STATUS_LED_COLOR_ORANGE but Led.STATUS_LED_COLOR_RED?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might display led color in CLI by calling get_status_led, and we want user to understand green=OK, red=Not OK. Different platform might support different LED color, this is to unify the behavior.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Junchao-Mellanox Got it. I found the get_status() returns STATUS_LED_COLOR_RED for both RED and ORANGE LED.

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