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

Redfish iDRAC: Added job_id to response for CreateBiosConfigJob (#6367)

* Redfish iDRAC: Added job_id to response for CreateBiosConfigJob

Signed-off-by: Mike Raineri <michael.raineri@dell.com>

* YAML fix to changelog fragment

Signed-off-by: Mike Raineri <michael.raineri@dell.com>

---------

Signed-off-by: Mike Raineri <michael.raineri@dell.com>
This commit is contained in:
Mike Raineri 2023-04-19 14:11:57 -04:00 committed by GitHub
parent 1aa94a5a1d
commit 087c5a53d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 5 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- idrac_redfish_command - add ``job_id`` to ``CreateBiosConfigJob`` response (https://github.com/ansible-collections/community.general/issues/5603).

View file

@ -85,6 +85,14 @@ msg:
returned: always returned: always
type: str type: str
sample: "Action was successful" sample: "Action was successful"
return_values:
description: Dictionary containing command-specific response data from the action.
returned: on success
type: dict
version_added: 6.6.0
sample: {
"job_id": "/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/JID_471269252011"
}
''' '''
import re import re
@ -128,10 +136,9 @@ class IdracRedfishUtils(RedfishUtils):
return response return response
response_output = response['resp'].__dict__ response_output = response['resp'].__dict__
job_id = response_output["headers"]["Location"] job_id_full = response_output["headers"]["Location"]
job_id = re.search("JID_.+", job_id).group() job_id = re.search("JID_.+", job_id_full).group()
# Currently not passing job_id back to user but patch is coming return {'ret': True, 'msg': "Config job %s created" % job_id, 'job_id': job_id_full}
return {'ret': True, 'msg': "Config job %s created" % job_id}
CATEGORY_COMMANDS_ALL = { CATEGORY_COMMANDS_ALL = {
@ -143,6 +150,7 @@ CATEGORY_COMMANDS_ALL = {
def main(): def main():
result = {} result = {}
return_values = {}
module = AnsibleModule( module = AnsibleModule(
argument_spec=dict( argument_spec=dict(
category=dict(required=True), category=dict(required=True),
@ -210,11 +218,13 @@ def main():
if result['ret'] is False: if result['ret'] is False:
module.fail_json(msg=to_native(result['msg'])) module.fail_json(msg=to_native(result['msg']))
result = rf_utils.create_bios_config_job() result = rf_utils.create_bios_config_job()
if 'job_id' in result:
return_values['job_id'] = result['job_id']
# Return data back or fail with proper message # Return data back or fail with proper message
if result['ret'] is True: if result['ret'] is True:
del result['ret'] del result['ret']
module.exit_json(changed=True, msg='Action was successful') module.exit_json(changed=True, msg='Action was successful', return_values=return_values)
else: else:
module.fail_json(msg=to_native(result['msg'])) module.fail_json(msg=to_native(result['msg']))