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:
parent
f7bc6964be
commit
98181fb8cb
2 changed files with 9 additions and 3 deletions
2
changelogs/fragments/7746-raw_post-without-actions.yml
Normal file
2
changelogs/fragments/7746-raw_post-without-actions.yml
Normal 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).
|
|
@ -592,8 +592,9 @@ class XCCRedfishUtils(RedfishUtils):
|
|||
def raw_post_resource(self, resource_uri, request_body):
|
||||
if resource_uri is None:
|
||||
return {'ret': False, 'msg': "resource_uri is missing"}
|
||||
resource_uri_has_actions = True
|
||||
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:
|
||||
return {'ret': False, 'msg': "request_body is missing"}
|
||||
# get action base uri data for further checking
|
||||
|
@ -602,7 +603,10 @@ class XCCRedfishUtils(RedfishUtils):
|
|||
if response['ret'] is False:
|
||||
return response
|
||||
if 'Actions' not in response['data']:
|
||||
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
|
||||
action_found = False
|
||||
|
@ -634,7 +638,7 @@ class XCCRedfishUtils(RedfishUtils):
|
|||
else:
|
||||
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,
|
||||
'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))}
|
||||
|
|
Loading…
Reference in a new issue