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

Implemented raw_post without actions (#7746)

* implemented raw_post without actions

* fixed identation

* added changelog fragment

* Update changelogs/fragments/7746-raw_post-without-actions.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Andrei Sucu 2023-12-28 19:11:43 +02:00 committed by GitHub
parent f7bc6964be
commit 98181fb8cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View file

@ -0,0 +1,2 @@
minor_changes:
- xcc_redfish_command - added support for raw POSTs (``command=PostResource`` in ``category=Raw``) without a specific action info (https://github.com/ansible-collections/community.general/pull/7746).

View file

@ -592,8 +592,9 @@ class XCCRedfishUtils(RedfishUtils):
def raw_post_resource(self, resource_uri, request_body): def raw_post_resource(self, resource_uri, request_body):
if resource_uri is None: if resource_uri is None:
return {'ret': False, 'msg': "resource_uri is missing"} return {'ret': False, 'msg': "resource_uri is missing"}
resource_uri_has_actions = True
if '/Actions/' not in resource_uri: if '/Actions/' not in resource_uri:
return {'ret': False, 'msg': "Bad uri %s. Keyword /Actions/ should be included in uri" % resource_uri} resource_uri_has_actions = False
if request_body is None: if request_body is None:
return {'ret': False, 'msg': "request_body is missing"} return {'ret': False, 'msg': "request_body is missing"}
# get action base uri data for further checking # get action base uri data for further checking
@ -602,7 +603,10 @@ class XCCRedfishUtils(RedfishUtils):
if response['ret'] is False: if response['ret'] is False:
return response return response
if 'Actions' not in response['data']: if 'Actions' not in response['data']:
return {'ret': False, 'msg': "Actions property not found in %s" % action_base_uri} if resource_uri_has_actions:
return {'ret': False, 'msg': "Actions property not found in %s" % action_base_uri}
else:
response['data']['Actions'] = {}
# check resouce_uri with target uri found in action base uri data # check resouce_uri with target uri found in action base uri data
action_found = False action_found = False
@ -634,7 +638,7 @@ class XCCRedfishUtils(RedfishUtils):
else: else:
action_target_uri_list.append(response['data']['Actions']['Oem'][key]['target']) action_target_uri_list.append(response['data']['Actions']['Oem'][key]['target'])
if not action_found: if not action_found and resource_uri_has_actions:
return {'ret': False, return {'ret': False,
'msg': 'Specified resource_uri is not a supported action target uri, please specify a supported target uri instead. Supported uri: %s' 'msg': 'Specified resource_uri is not a supported action target uri, please specify a supported target uri instead. Supported uri: %s'
% (str(action_target_uri_list))} % (str(action_target_uri_list))}