[Mellanox] [202012] Allow user to set LED to orange (#9514)

Backport https://github.com/Azure/sonic-buildimage/pull/9259 to 202012

#### 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

Manual test
This commit is contained in:
Junchao-Mellanox 2021-12-14 08:04:06 +08:00 committed by GitHub
parent 0226140e9c
commit 0197855d5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,6 +41,17 @@ class Led(object):
else:
return False
with open(led_path, 'w') as led:
led.write(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
with open(led_path, 'w') as led:
led.write(Led.LED_ON)
status = True
@ -158,7 +169,7 @@ class Led(object):
cap_list = set(caps.split())
except (ValueError, IOError):
pass
return cap_list
def get_green_led_path(self):
@ -191,7 +202,7 @@ class Led(object):
def get_led_cap_path(self):
pass
class FanLed(Led):
LED_PATH = "/var/run/hw-management/led/"