mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-23 19:01:26 -07:00
* WDC Redfish support for chassis indicator LED toggling.
* Added changelog fragment.
* Apply suggestions from code review
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 6062ae8fae
)
Co-authored-by: Mike Moerk <mike@moerk.org>
This commit is contained in:
parent
6a029bcba3
commit
df59034d75
4 changed files with 245 additions and 18 deletions
|
@ -405,3 +405,50 @@ class WdcRedfishUtils(RedfishUtils):
|
|||
return iom_b_firmware_version
|
||||
else:
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
def _get_led_locate_uri(data):
|
||||
"""Get the LED locate URI given a resource body."""
|
||||
if "Actions" not in data:
|
||||
return None
|
||||
if "Oem" not in data["Actions"]:
|
||||
return None
|
||||
if "WDC" not in data["Actions"]["Oem"]:
|
||||
return None
|
||||
if "#Chassis.Locate" not in data["Actions"]["Oem"]["WDC"]:
|
||||
return None
|
||||
if "target" not in data["Actions"]["Oem"]["WDC"]["#Chassis.Locate"]:
|
||||
return None
|
||||
return data["Actions"]["Oem"]["WDC"]["#Chassis.Locate"]["target"]
|
||||
|
||||
def manage_indicator_led(self, command, resource_uri):
|
||||
key = 'IndicatorLED'
|
||||
|
||||
payloads = {'IndicatorLedOn': 'On', 'IndicatorLedOff': 'Off'}
|
||||
current_led_status_map = {'IndicatorLedOn': 'Blinking', 'IndicatorLedOff': 'Off'}
|
||||
|
||||
result = {}
|
||||
response = self.get_request(self.root_uri + resource_uri)
|
||||
if response['ret'] is False:
|
||||
return response
|
||||
result['ret'] = True
|
||||
data = response['data']
|
||||
if key not in data:
|
||||
return {'ret': False, 'msg': "Key %s not found" % key}
|
||||
current_led_status = data[key]
|
||||
if current_led_status == current_led_status_map[command]:
|
||||
return {'ret': True, 'changed': False}
|
||||
|
||||
led_locate_uri = self._get_led_locate_uri(data)
|
||||
if led_locate_uri is None:
|
||||
return {'ret': False, 'msg': 'LED locate URI not found.'}
|
||||
|
||||
if command in payloads.keys():
|
||||
payload = {'LocateState': payloads[command]}
|
||||
response = self.post_request(self.root_uri + led_locate_uri, payload)
|
||||
if response['ret'] is False:
|
||||
return response
|
||||
else:
|
||||
return {'ret': False, 'msg': 'Invalid command'}
|
||||
|
||||
return result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue