Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
fixes:
- |
Fixes virtual media insertion on BMCs (such as Cisco C845A M8 with
Redfish Base.1.18.1) that return ``ActionParameterMissing`` for the
missing ``TransferProtocolType`` parameter without including a
``RelatedProperties`` field in the error response. The
``is_transfer_protocol_required`` method now also checks for the
parameter name in ``MessageArgs`` as a fallback.
26 changes: 20 additions & 6 deletions sushy/resources/manager/virtual_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,26 @@ def is_transfer_protocol_required(self, error=None):
and 'TransferProtocolType' in error.detail):
return True

return (
(error.code.endswith(".ActionParameterMissing")
or error.code.endswith(".PropertyMissing"))
and (("#/TransferProtocolType" in error.related_properties)
or ("/TransferProtocolType" in error.related_properties))
)
if not (error.code.endswith(".ActionParameterMissing")
or error.code.endswith(".PropertyMissing")):
return False

if (("#/TransferProtocolType" in error.related_properties)
or ("/TransferProtocolType" in error.related_properties)):
return True

# NOTE(janders) Some BMCs (e.g. Cisco C845A M8 with Redfish
# Base.1.18.1) do not include RelatedProperties in the error
# response, but do include the missing parameter name in
# MessageArgs. Check for that as a fallback.
try:
args = error.extended_info[0].get('MessageArgs', [])
if 'TransferProtocolType' in args:
return True
except (IndexError, KeyError, TypeError):
pass

return False

def is_transfer_method_required(self, error=None):
"""Check the response code and body and in case of failure
Expand Down
19 changes: 19 additions & 0 deletions sushy/tests/unit/json_samples/transfer_proto_required_error4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"error": {
"@Message.ExtendedInfo": [
{
"@odata.type": "#Message.v1_1_1.Message",
"Message": "The action InsertMedia requires the parameter TransferProtocolType to be present in the request body.",
"MessageArgs": [
"InsertMedia",
"TransferProtocolType"
],
"MessageId": "Base.1.18.1.ActionParameterMissing",
"MessageSeverity": "Critical",
"Resolution": "Supply the action with the required parameter in the request body when the request is resubmitted."
}
],
"code": "Base.1.18.1.ActionParameterMissing",
"message": "The action InsertMedia requires the parameter TransferProtocolType to be present in the request body."
}
}
10 changes: 10 additions & 0 deletions sushy/tests/unit/resources/manager/test_virtual_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,16 @@ def test_is_transfer_protocol_required_alt3(self):
retval = self.sys_virtual_media.is_transfer_protocol_required(error)
self.assertTrue(retval)

def test_is_transfer_protocol_required_no_related_properties(self):
with open('sushy/tests/unit/json_samples/'
'transfer_proto_required_error4.json') as f:
response_obj = json.load(f)
response = mock.Mock(spec=['json', 'status_code'])
response.json.return_value = response_obj
error = exceptions.HTTPError('POST', 'VirtualMedia', response)
retval = self.sys_virtual_media.is_transfer_protocol_required(error)
self.assertTrue(retval)

def test_is_transfer_method_required(self):
with open('sushy/tests/unit/json_samples/'
'transfer_method_required_error.json') as f:
Expand Down