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

Redfish: Add support for OemParameters (#8825)

AMI BMC requires a separate OemParameters json to set the image type
when doing MultipartHTTPPushUpdate.

The patch adds a new option update_image_type to support it.
Test OK with AMI BMC 13.3.

Signed-off-by: Chih-Wei Huang <cwhuang@android-x86.org>
This commit is contained in:
Chih-Wei Huang 2024-09-03 16:47:16 +08:00
parent 62b0336dff
commit e3ac64c3ee
2 changed files with 13 additions and 0 deletions

View file

@ -1863,6 +1863,7 @@ class RedfishUtils(object):
targets = update_opts.get('update_targets') targets = update_opts.get('update_targets')
apply_time = update_opts.get('update_apply_time') apply_time = update_opts.get('update_apply_time')
oem_params = update_opts.get('update_oem_params') oem_params = update_opts.get('update_oem_params')
image_type = update_opts.get('update_image_type')
# Ensure the image file is provided # Ensure the image file is provided
if not image_file: if not image_file:
@ -1899,6 +1900,9 @@ class RedfishUtils(object):
'UpdateParameters': {'content': json.dumps(payload), 'mime_type': 'application/json'}, 'UpdateParameters': {'content': json.dumps(payload), 'mime_type': 'application/json'},
'UpdateFile': {'filename': image_file, 'content': image_payload, 'mime_type': 'application/octet-stream'} 'UpdateFile': {'filename': image_file, 'content': image_payload, 'mime_type': 'application/octet-stream'}
} }
if image_type:
payload = {'ImageType': image_type}
multipart_payload["OemParameters"] = {'content': json.dumps(payload), 'mime_type': 'application/json'}
response = self.post_request(self.root_uri + update_uri, multipart_payload, multipart=True) response = self.post_request(self.root_uri + update_uri, multipart_payload, multipart=True)
if response['ret'] is False: if response['ret'] is False:
return response return response

View file

@ -161,6 +161,12 @@ options:
- Filename, with optional path, of the image for the update. - Filename, with optional path, of the image for the update.
type: path type: path
version_added: '7.1.0' version_added: '7.1.0'
update_image_type:
required: false
description:
- The image type to be set in OemParameters for the update.
type: str
version_added: '9.4.0'
update_protocol: update_protocol:
required: false required: false
description: description:
@ -626,6 +632,7 @@ EXAMPLES = '''
password: "{{ password }}" password: "{{ password }}"
timeout: 600 timeout: 600
update_image_file: ~/images/myupdate.img update_image_file: ~/images/myupdate.img
update_image_type: BMC
- name: Multipart HTTP push with additional options; timeout is 600 seconds - name: Multipart HTTP push with additional options; timeout is 600 seconds
to allow for a large image transfer to allow for a large image transfer
@ -848,6 +855,7 @@ def main():
resource_id=dict(), resource_id=dict(),
update_image_uri=dict(), update_image_uri=dict(),
update_image_file=dict(type='path'), update_image_file=dict(type='path'),
update_image_type=dict(),
update_protocol=dict(), update_protocol=dict(),
update_targets=dict(type='list', elements='str', default=[]), update_targets=dict(type='list', elements='str', default=[]),
update_oem_params=dict(type='dict'), update_oem_params=dict(type='dict'),
@ -923,6 +931,7 @@ def main():
update_opts = { update_opts = {
'update_image_uri': module.params['update_image_uri'], 'update_image_uri': module.params['update_image_uri'],
'update_image_file': module.params['update_image_file'], 'update_image_file': module.params['update_image_file'],
'update_image_type': module.params['update_image_type'],
'update_protocol': module.params['update_protocol'], 'update_protocol': module.params['update_protocol'],
'update_targets': module.params['update_targets'], 'update_targets': module.params['update_targets'],
'update_creds': module.params['update_creds'], 'update_creds': module.params['update_creds'],