From 4e4cdcabc0a26398e4ed0300f4ea59d604138122 Mon Sep 17 00:00:00 2001 From: Satoshi I Date: Mon, 5 Jun 2023 19:44:12 +0900 Subject: [PATCH] fix: idrac_server_config_profile.py to wait until scp is applied --- plugins/module_utils/idrac_redfish.py | 3 --- plugins/modules/idrac_server_config_profile.py | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/plugins/module_utils/idrac_redfish.py b/plugins/module_utils/idrac_redfish.py index c19632a71..75497043d 100644 --- a/plugins/module_utils/idrac_redfish.py +++ b/plugins/module_utils/idrac_redfish.py @@ -354,9 +354,6 @@ def import_scp_share(self, shutdown_type=None, host_powerstate=None, job_wait=Tr if share.get("proxy_password") is not None: payload["ShareParameters"]["ProxyPassword"] = share["proxy_password"] response = self.invoke_request(IMPORT_URI, "POST", data=payload) - if response.status_code == 202 and job_wait: - task_uri = response.headers["Location"] - response = self.wait_for_job_complete(task_uri, job_wait=job_wait) return response def import_preview(self, import_buffer=None, target=None, share=None, job_wait=False): diff --git a/plugins/modules/idrac_server_config_profile.py b/plugins/modules/idrac_server_config_profile.py index 00f621177..c2956bf3e 100644 --- a/plugins/modules/idrac_server_config_profile.py +++ b/plugins/modules/idrac_server_config_profile.py @@ -518,7 +518,8 @@ from os.path import exists from ansible.module_utils.basic import AnsibleModule from ansible_collections.dellemc.openmanage.plugins.module_utils.idrac_redfish import iDRACRedfishAPI, idrac_auth_params -from ansible_collections.dellemc.openmanage.plugins.module_utils.utils import strip_substr_dict +from ansible_collections.dellemc.openmanage.plugins.module_utils.utils import idrac_redfish_job_tracking, \ + strip_substr_dict from ansible.module_utils.six.moves.urllib.error import URLError, HTTPError from ansible.module_utils.urls import ConnectionError, SSLValidationError from ansible.module_utils.six.moves.urllib.parse import urlparse @@ -535,6 +536,9 @@ SCP_ALL_ERR_MSG = "The option ALL cannot be used with options IDRAC, BIOS, NIC, or RAID." MUTUALLY_EXCLUSIVE = "import_buffer is mutually exclusive with {0}." PROXY_ERR_MSG = "proxy_support is enabled but all of the following are missing: proxy_server" +iDRAC_JOB_URI = "/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/{job_id}" +SUCCESS_COMPLETE = "Successfully applied the iDRAC attributes update." +SCHEDULED_SUCCESS = "Successfully scheduled the job for the iDRAC attributes update." def get_scp_file_format(module): @@ -555,7 +559,8 @@ def get_scp_file_format(module): def response_format_change(response, params, file_name): resp = {} if params["job_wait"]: - response = response.json_data + if hasattr(response, "json_data"): + response = response.json_data response.pop("Description", None) response.pop("Name", None) response.pop("EndTime", None) @@ -807,6 +812,11 @@ def import_scp_redfish(module, idrac, http_share): job_wait=module.params["job_wait"], target=scp_targets, import_buffer=buffer_text, share=share_dict, ) + job_id = scp_response.headers["Location"].split("/")[-1] + if module.params["job_wait"]: + job_failed, msg, job_dict, wait_time = idrac_redfish_job_tracking( + idrac, iDRAC_JOB_URI.format(job_id=job_id)) + scp_response = job_dict else: scp_response = idrac.import_scp(import_buffer=import_buffer, target=scp_targets, job_wait=module.params["job_wait"]) scp_response = response_format_change(scp_response, module.params, share.get("file_name"))