1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Redfish: Added IndicatorLED commands to the Systems category (#4458) (#4494)

* Redfish: Added IndicatorLED commands to the Systems category

Signed-off-by: Mike Raineri <michael.raineri@dell.com>

* Method call typo fix

Signed-off-by: Mike Raineri <michael.raineri@dell.com>

* Update 4084-add-redfish-system-indicator-led.yml

* Backwards compatibility suggestion

Signed-off-by: Mike Raineri <michael.raineri@dell.com>
(cherry picked from commit a9125c02e7)

Co-authored-by: Mike Raineri <michael.raineri@dell.com>
This commit is contained in:
patchback[bot] 2022-04-11 20:22:58 +02:00 committed by GitHub
parent bec382df87
commit 6a74c46e1c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 5 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- redfish_command - add ``IndicatorLedOn``, ``IndicatorLedOff``, and ``IndicatorLedBlink`` commands to the Systems category for controling system LEDs (https://github.com/ansible-collections/community.general/issues/4084).

View file

@ -732,14 +732,22 @@ class RedfishUtils(object):
def get_multi_volume_inventory(self): def get_multi_volume_inventory(self):
return self.aggregate_systems(self.get_volume_inventory) return self.aggregate_systems(self.get_volume_inventory)
def manage_indicator_led(self, command): def manage_system_indicator_led(self, command):
return self.manage_indicator_led(command, self.systems_uri)
def manage_chassis_indicator_led(self, command):
return self.manage_indicator_led(command, self.chassis_uri)
def manage_indicator_led(self, command, resource_uri=None):
result = {} result = {}
key = 'IndicatorLED' key = 'IndicatorLED'
if resource_uri is None:
resource_uri = self.chassis_uri
payloads = {'IndicatorLedOn': 'Lit', 'IndicatorLedOff': 'Off', "IndicatorLedBlink": 'Blinking'} payloads = {'IndicatorLedOn': 'Lit', 'IndicatorLedOff': 'Off', "IndicatorLedBlink": 'Blinking'}
result = {} result = {}
response = self.get_request(self.root_uri + self.chassis_uri) response = self.get_request(self.root_uri + resource_uri)
if response['ret'] is False: if response['ret'] is False:
return response return response
result['ret'] = True result['ret'] = True
@ -749,7 +757,7 @@ class RedfishUtils(object):
if command in payloads.keys(): if command in payloads.keys():
payload = {'IndicatorLED': payloads[command]} payload = {'IndicatorLED': payloads[command]}
response = self.patch_request(self.root_uri + self.chassis_uri, payload) response = self.patch_request(self.root_uri + resource_uri, payload)
if response['ret'] is False: if response['ret'] is False:
return response return response
else: else:

View file

@ -318,6 +318,14 @@ EXAMPLES = '''
category: Systems category: Systems
command: DisableBootOverride command: DisableBootOverride
- name: Set system indicator LED to blink using security token for auth
community.general.redfish_command:
category: Systems
command: IndicatorLedBlink
resource_id: 437XR1138R2
baseuri: "{{ baseuri }}"
auth_token: "{{ result.session.token }}"
- name: Add user - name: Add user
community.general.redfish_command: community.general.redfish_command:
category: Accounts category: Accounts
@ -583,7 +591,8 @@ from ansible.module_utils.common.text.converters import to_native
# More will be added as module features are expanded # More will be added as module features are expanded
CATEGORY_COMMANDS_ALL = { CATEGORY_COMMANDS_ALL = {
"Systems": ["PowerOn", "PowerForceOff", "PowerForceRestart", "PowerGracefulRestart", "Systems": ["PowerOn", "PowerForceOff", "PowerForceRestart", "PowerGracefulRestart",
"PowerGracefulShutdown", "PowerReboot", "SetOneTimeBoot", "EnableContinuousBootOverride", "DisableBootOverride"], "PowerGracefulShutdown", "PowerReboot", "SetOneTimeBoot", "EnableContinuousBootOverride", "DisableBootOverride",
"IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink"],
"Chassis": ["IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink"], "Chassis": ["IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink"],
"Accounts": ["AddUser", "EnableUser", "DeleteUser", "DisableUser", "Accounts": ["AddUser", "EnableUser", "DeleteUser", "DisableUser",
"UpdateUserRole", "UpdateUserPassword", "UpdateUserName", "UpdateUserRole", "UpdateUserPassword", "UpdateUserName",
@ -754,6 +763,8 @@ def main():
elif command == "DisableBootOverride": elif command == "DisableBootOverride":
boot_opts['override_enabled'] = 'Disabled' boot_opts['override_enabled'] = 'Disabled'
result = rf_utils.set_boot_override(boot_opts) result = rf_utils.set_boot_override(boot_opts)
elif command.startswith('IndicatorLed'):
result = rf_utils.manage_system_indicator_led(command)
elif category == "Chassis": elif category == "Chassis":
result = rf_utils._find_chassis_resource() result = rf_utils._find_chassis_resource()
@ -769,7 +780,7 @@ def main():
else: else:
for command in command_list: for command in command_list:
if command in led_commands: if command in led_commands:
result = rf_utils.manage_indicator_led(command) result = rf_utils.manage_chassis_indicator_led(command)
elif category == "Sessions": elif category == "Sessions":
# execute only if we find SessionService resources # execute only if we find SessionService resources