Add IndicatorLED control commands to redfish_command module (#53752)

* Add Chassis commands IndicatorLedOn, IndicatorLedOff, and IndicatorLedBlink

* Add manage_indicator_led function to redfish_utils

* Add Chassis command category with IndicatorLedOn/Off/Blink commands to redfish_command

* Add IndicatorLedBlink example to EXAMPLES docstring, and make the category == 'Chassis' section more generic for future development
This commit is contained in:
Xander Madsen 2019-03-28 16:58:46 -04:00 committed by John R Barker
commit 31b02fdd58
2 changed files with 51 additions and 0 deletions

View file

@ -96,6 +96,14 @@ EXAMPLES = '''
username: "{{ username }}"
password: "{{ password }}"
- name: Set chassis indicator LED to blink
redfish_command:
category: Chassis
command: IndicatorLedBlink
baseuri: "{{ baseuri }}"
username: "{{ username }}"
password: "{{ password }}"
- name: Add and enable user
redfish_command:
category: Accounts
@ -154,6 +162,7 @@ from ansible.module_utils._text import to_native
CATEGORY_COMMANDS_ALL = {
"Systems": ["PowerOn", "PowerForceOff", "PowerGracefulRestart",
"PowerGracefulShutdown", "PowerReboot", "SetOneTimeBoot"],
"Chassis": ["IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink"],
"Accounts": ["AddUser", "EnableUser", "DeleteUser", "DisableUser",
"UpdateUserRole", "UpdateUserPassword"],
"Manager": ["GracefulRestart", "ClearLogs"],
@ -241,6 +250,22 @@ def main():
elif command == "SetOneTimeBoot":
result = rf_utils.set_one_time_boot_device(module.params['bootdevice'])
elif category == "Chassis":
result = rf_utils._find_chassis_resource(rf_uri)
if result['ret'] is False:
module.fail_json(msg=to_native(result['msg']))
led_commands = ["IndicatorLedOn", "IndicatorLedOff", "IndicatorLedBlink"]
# Check if more than one led_command is present
num_led_commands = sum([command in led_commands for command in command_list])
if num_led_commands > 1:
result = {'ret': False, 'msg': "Only one IndicatorLed command should be sent at a time."}
else:
for command in command_list:
if command in led_commands:
result = rf_utils.manage_indicator_led(command)
elif category == "Manager":
MANAGER_COMMANDS = {
"GracefulRestart": rf_utils.restart_manager_gracefully,