From e3ac64c3ee2b75888e75edbc1c0f17146612a9fa Mon Sep 17 00:00:00 2001 From: Chih-Wei Huang Date: Tue, 3 Sep 2024 16:47:16 +0800 Subject: [PATCH] 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 --- plugins/module_utils/redfish_utils.py | 4 ++++ plugins/modules/redfish_command.py | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/plugins/module_utils/redfish_utils.py b/plugins/module_utils/redfish_utils.py index 220ce5c81a..7c43063cd9 100644 --- a/plugins/module_utils/redfish_utils.py +++ b/plugins/module_utils/redfish_utils.py @@ -1863,6 +1863,7 @@ class RedfishUtils(object): targets = update_opts.get('update_targets') apply_time = update_opts.get('update_apply_time') oem_params = update_opts.get('update_oem_params') + image_type = update_opts.get('update_image_type') # Ensure the image file is provided if not image_file: @@ -1899,6 +1900,9 @@ class RedfishUtils(object): 'UpdateParameters': {'content': json.dumps(payload), 'mime_type': 'application/json'}, '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) if response['ret'] is False: return response diff --git a/plugins/modules/redfish_command.py b/plugins/modules/redfish_command.py index f9b0c8bd3b..a90ed91c64 100644 --- a/plugins/modules/redfish_command.py +++ b/plugins/modules/redfish_command.py @@ -161,6 +161,12 @@ options: - Filename, with optional path, of the image for the update. type: path 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: required: false description: @@ -626,6 +632,7 @@ EXAMPLES = ''' password: "{{ password }}" timeout: 600 update_image_file: ~/images/myupdate.img + update_image_type: BMC - name: Multipart HTTP push with additional options; timeout is 600 seconds to allow for a large image transfer @@ -848,6 +855,7 @@ def main(): resource_id=dict(), update_image_uri=dict(), update_image_file=dict(type='path'), + update_image_type=dict(), update_protocol=dict(), update_targets=dict(type='list', elements='str', default=[]), update_oem_params=dict(type='dict'), @@ -923,6 +931,7 @@ def main(): update_opts = { 'update_image_uri': module.params['update_image_uri'], 'update_image_file': module.params['update_image_file'], + 'update_image_type': module.params['update_image_type'], 'update_protocol': module.params['update_protocol'], 'update_targets': module.params['update_targets'], 'update_creds': module.params['update_creds'],