Fix #Bios.ResetBios for HTTP 400 Bad request error
Different BMCs return different HTTP errors when encountering missing POST body for BIOS factory reset. This fixes for iDRAC 2.75.75.75 that returns HTTP 400 Bad request. Newer iDRAC versions can handle missing POST body without errors. Change-Id: I2427820e7586b559ae81c3b623a4c1871b561516 Story: 2008198 Task: 40978
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes an issue in performing action ``#Bios.ResetBios`` when no body in
|
||||
POST request provided and BMC responds with HTTP 400 Bad request, for
|
||||
example, Dell R630 having iDRAC 2.75.75.75. See `story 2008198
|
||||
<https://storyboard.openstack.org/#!/story/2008198>`__ for details.
|
||||
@@ -212,7 +212,8 @@ class Bios(base.ResourceBase):
|
||||
self._conn.post(target_uri)
|
||||
except exceptions.HTTPError as resp:
|
||||
# Send empty payload, if BMC expects body
|
||||
if resp.status_code == http_client.UNSUPPORTED_MEDIA_TYPE:
|
||||
if resp.status_code in [http_client.UNSUPPORTED_MEDIA_TYPE,
|
||||
http_client.BAD_REQUEST]:
|
||||
self._conn.post(target_uri, data={})
|
||||
else:
|
||||
raise
|
||||
|
||||
@@ -256,6 +256,18 @@ class BiosTestCase(base.TestCase):
|
||||
self.sys_bios.reset_bios()
|
||||
self.sys_bios._conn.post.assert_has_calls(post_calls)
|
||||
|
||||
def test_reset_bios_handle_http_error_400(self):
|
||||
|
||||
target_uri = (
|
||||
'/redfish/v1/Systems/437XR1138R2/BIOS/Actions/Bios.ResetBios')
|
||||
self.conn.post.side_effect = [exceptions.HTTPError(
|
||||
method='POST', url=target_uri, response=mock.MagicMock(
|
||||
status_code=http_client.BAD_REQUEST)), '200']
|
||||
post_calls = [
|
||||
mock.call(target_uri), mock.call(target_uri, data={})]
|
||||
self.sys_bios.reset_bios()
|
||||
self.sys_bios._conn.post.assert_has_calls(post_calls)
|
||||
|
||||
def test_reset_bios_handle_http_error_405(self):
|
||||
|
||||
target_uri = (
|
||||
|
||||
Reference in New Issue
Block a user