mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-13 17:44:22 -07:00
Redfish: Expanded SimpleUpdate command to allow for users to monitor the progress of an update and perform follow-up operations (#5580)
* Redfish: Expanded SimpleUpdate command to allow for users to monitor the progress of an update and perform follow-up operations * Update changelogs/fragments/3910-redfish-add-operation-apply-time-to-simple-update.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/redfish_command.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update changelogs/fragments/4276-redfish-command-updates-for-full-simple-update-workflow.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Updated based on feedback and CI results * Update plugins/modules/redfish_command.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/redfish_command.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/redfish_info.py Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
3bf3d6bff4
commit
5c1c8152ec
5 changed files with 218 additions and 8 deletions
|
@ -161,6 +161,24 @@ options:
|
|||
description:
|
||||
- Password for retrieving the update image.
|
||||
type: str
|
||||
update_apply_time:
|
||||
required: false
|
||||
description:
|
||||
- Time when to apply the update.
|
||||
type: str
|
||||
choices:
|
||||
- Immediate
|
||||
- OnReset
|
||||
- AtMaintenanceWindowStart
|
||||
- InMaintenanceWindowOnReset
|
||||
- OnStartUpdateRequest
|
||||
version_added: '6.1.0'
|
||||
update_handle:
|
||||
required: false
|
||||
description:
|
||||
- Handle to check the status of an update in progress.
|
||||
type: str
|
||||
version_added: '6.1.0'
|
||||
virtual_media:
|
||||
required: false
|
||||
description:
|
||||
|
@ -508,6 +526,15 @@ EXAMPLES = '''
|
|||
username: operator
|
||||
password: supersecretpwd
|
||||
|
||||
- name: Perform requested operations to continue the update
|
||||
community.general.redfish_command:
|
||||
category: Update
|
||||
command: PerformRequestedOperations
|
||||
baseuri: "{{ baseuri }}"
|
||||
username: "{{ username }}"
|
||||
password: "{{ password }}"
|
||||
update_handle: /redfish/v1/TaskService/TaskMonitors/735
|
||||
|
||||
- name: Insert Virtual Media
|
||||
community.general.redfish_command:
|
||||
category: Systems
|
||||
|
@ -610,6 +637,20 @@ msg:
|
|||
returned: always
|
||||
type: str
|
||||
sample: "Action was successful"
|
||||
return_values:
|
||||
description: Dictionary containing command-specific response data from the action.
|
||||
returned: on success
|
||||
type: dict
|
||||
version_added: 6.1.0
|
||||
sample: {
|
||||
"update_status": {
|
||||
"handle": "/redfish/v1/TaskService/TaskMonitors/735",
|
||||
"messages": [],
|
||||
"resets_requested": [],
|
||||
"ret": true,
|
||||
"status": "New"
|
||||
}
|
||||
}
|
||||
'''
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
@ -630,12 +671,13 @@ CATEGORY_COMMANDS_ALL = {
|
|||
"Manager": ["GracefulRestart", "ClearLogs", "VirtualMediaInsert",
|
||||
"VirtualMediaEject", "PowerOn", "PowerForceOff", "PowerForceRestart",
|
||||
"PowerGracefulRestart", "PowerGracefulShutdown", "PowerReboot"],
|
||||
"Update": ["SimpleUpdate"]
|
||||
"Update": ["SimpleUpdate", "PerformRequestedOperations"],
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
result = {}
|
||||
return_values = {}
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
category=dict(required=True),
|
||||
|
@ -667,6 +709,9 @@ def main():
|
|||
password=dict(no_log=True)
|
||||
)
|
||||
),
|
||||
update_apply_time=dict(choices=['Immediate', 'OnReset', 'AtMaintenanceWindowStart',
|
||||
'InMaintenanceWindowOnReset', 'OnStartUpdateRequest']),
|
||||
update_handle=dict(),
|
||||
virtual_media=dict(
|
||||
type='dict',
|
||||
options=dict(
|
||||
|
@ -721,7 +766,9 @@ def main():
|
|||
'update_image_uri': module.params['update_image_uri'],
|
||||
'update_protocol': module.params['update_protocol'],
|
||||
'update_targets': module.params['update_targets'],
|
||||
'update_creds': module.params['update_creds']
|
||||
'update_creds': module.params['update_creds'],
|
||||
'update_apply_time': module.params['update_apply_time'],
|
||||
'update_handle': module.params['update_handle'],
|
||||
}
|
||||
|
||||
# Boot override options
|
||||
|
@ -859,6 +906,10 @@ def main():
|
|||
for command in command_list:
|
||||
if command == "SimpleUpdate":
|
||||
result = rf_utils.simple_update(update_opts)
|
||||
if 'update_status' in result:
|
||||
return_values['update_status'] = result['update_status']
|
||||
elif command == "PerformRequestedOperations":
|
||||
result = rf_utils.perform_requested_update_operations(update_opts['update_handle'])
|
||||
|
||||
# Return data back or fail with proper message
|
||||
if result['ret'] is True:
|
||||
|
@ -866,7 +917,8 @@ def main():
|
|||
changed = result.get('changed', True)
|
||||
session = result.get('session', dict())
|
||||
module.exit_json(changed=changed, session=session,
|
||||
msg='Action was successful')
|
||||
msg='Action was successful',
|
||||
return_values=return_values)
|
||||
else:
|
||||
module.fail_json(msg=to_native(result['msg']))
|
||||
|
||||
|
|
|
@ -58,6 +58,12 @@ options:
|
|||
- Timeout in seconds for HTTP requests to OOB controller.
|
||||
default: 10
|
||||
type: int
|
||||
update_handle:
|
||||
required: false
|
||||
description:
|
||||
- Handle to check the status of an update in progress.
|
||||
type: str
|
||||
version_added: '6.1.0'
|
||||
|
||||
author: "Jose Delarosa (@jose-delarosa)"
|
||||
'''
|
||||
|
@ -247,6 +253,15 @@ EXAMPLES = '''
|
|||
username: "{{ username }}"
|
||||
password: "{{ password }}"
|
||||
|
||||
- name: Get the status of an update operation
|
||||
community.general.redfish_info:
|
||||
category: Update
|
||||
command: GetUpdateStatus
|
||||
baseuri: "{{ baseuri }}"
|
||||
username: "{{ username }}"
|
||||
password: "{{ password }}"
|
||||
update_handle: /redfish/v1/TaskService/TaskMonitors/735
|
||||
|
||||
- name: Get Manager Services
|
||||
community.general.redfish_info:
|
||||
category: Manager
|
||||
|
@ -324,7 +339,8 @@ CATEGORY_COMMANDS_ALL = {
|
|||
"GetChassisThermals", "GetChassisInventory", "GetHealthReport"],
|
||||
"Accounts": ["ListUsers"],
|
||||
"Sessions": ["GetSessions"],
|
||||
"Update": ["GetFirmwareInventory", "GetFirmwareUpdateCapabilities", "GetSoftwareInventory"],
|
||||
"Update": ["GetFirmwareInventory", "GetFirmwareUpdateCapabilities", "GetSoftwareInventory",
|
||||
"GetUpdateStatus"],
|
||||
"Manager": ["GetManagerNicInventory", "GetVirtualMedia", "GetLogs", "GetNetworkProtocols",
|
||||
"GetHealthReport", "GetHostInterfaces", "GetManagerInventory"],
|
||||
}
|
||||
|
@ -350,7 +366,8 @@ def main():
|
|||
username=dict(),
|
||||
password=dict(no_log=True),
|
||||
auth_token=dict(no_log=True),
|
||||
timeout=dict(type='int', default=10)
|
||||
timeout=dict(type='int', default=10),
|
||||
update_handle=dict(),
|
||||
),
|
||||
required_together=[
|
||||
('username', 'password'),
|
||||
|
@ -372,6 +389,9 @@ def main():
|
|||
# timeout
|
||||
timeout = module.params['timeout']
|
||||
|
||||
# update handle
|
||||
update_handle = module.params['update_handle']
|
||||
|
||||
# Build root URI
|
||||
root_uri = "https://" + module.params['baseuri']
|
||||
rf_utils = RedfishUtils(creds, root_uri, timeout, module)
|
||||
|
@ -482,6 +502,8 @@ def main():
|
|||
result["software"] = rf_utils.get_software_inventory()
|
||||
elif command == "GetFirmwareUpdateCapabilities":
|
||||
result["firmware_update_capabilities"] = rf_utils.get_firmware_update_capabilities()
|
||||
elif command == "GetUpdateStatus":
|
||||
result["update_status"] = rf_utils.get_update_status(update_handle)
|
||||
|
||||
elif category == "Sessions":
|
||||
# execute only if we find SessionService resources
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue