Add TransferProtocolType for any general error that mentions it

Story: 2010621
Task: 47554
Change-Id: I0d1a200c3fe3d4806d660553ee2f59b8d217f06c
This commit is contained in:
Derek Higgins 2023-02-28 15:00:35 +00:00
parent a59cf6c698
commit 2506b87d87
4 changed files with 35 additions and 1 deletions

View File

@ -0,0 +1,4 @@
---
fixes:
- |
Add TransferProtocolType for any general error that mentions it

View File

@ -111,6 +111,10 @@ class VirtualMedia(base.ResourceBase):
Try to determine if it happened due to missing TransferProtocolType.
"""
if (error.code.endswith('GeneralError')
and 'TransferProtocolType' in error.detail):
return True
return (
(error.code.endswith(".ActionParameterMissing")
or error.code.endswith(".PropertyMissing"))

View File

@ -0,0 +1,16 @@
{
"error": {
"code": "Base.1.4.0.GeneralError",
"message": "See ExtendedInfo for more information.",
"@Message.ExtendedInfo": [
{
"@odata.type": "Message.v1_0_6.Message",
"MessageId": "Base.1.4.0.GeneralError",
"Message": "'TransferProtocolType' property which is mandatory to complete the action is missing in the request body.",
"MessageArgs": [],
"Severity": "Critical"
}
]
}
}

View File

@ -186,7 +186,7 @@ class VirtualMediaTestCase(base.TestCase):
retval = self.sys_virtual_media.is_transfer_protocol_required(error)
self.assertTrue(retval)
def test_is_transfer_protocol_required_alt_code(self):
def test_is_transfer_protocol_required_alt(self):
with open('sushy/tests/unit/json_samples/'
'transfer_proto_required_error.json') as f:
response_obj = json.load(f)
@ -197,6 +197,16 @@ class VirtualMediaTestCase(base.TestCase):
retval = self.sys_virtual_media.is_transfer_protocol_required(error)
self.assertTrue(retval)
def test_is_transfer_protocol_required_alt2(self):
with open('sushy/tests/unit/json_samples/'
'transfer_proto_required_error2.json') as f:
response_obj = json.load(f)
response = mock.Mock(spec=['json', 'status_code'])
response.json.return_value = response_obj
error = exceptions.HTTPError('GET', 'VirtualMedia', response)
retval = self.sys_virtual_media.is_transfer_protocol_required(error)
self.assertTrue(retval)
def test_eject_media_none(self):
self.sys_virtual_media._actions.eject_media = None
self.assertRaisesRegex(