Fix programmatic error in heartbeat()
This patch is fixing a programmatic error in the heartbeat() method of the APIClient() class. When 409 (Conflict) was returned from the the Ironic API the code wasn't parsing the content of the response correctly. Change-Id: I01fbb8d866b2f94fe128d0bc40b69d05b5add1a3 Closes-Bug: #1556199
This commit is contained in:
@@ -73,7 +73,7 @@ class APIClient(object):
|
|||||||
raise errors.HeartbeatError(str(e))
|
raise errors.HeartbeatError(str(e))
|
||||||
|
|
||||||
if response.status_code == requests.codes.CONFLICT:
|
if response.status_code == requests.codes.CONFLICT:
|
||||||
data = response.json
|
data = json.loads(response.content)
|
||||||
raise errors.HeartbeatConflictError(data.get('faultstring'))
|
raise errors.HeartbeatConflictError(data.get('faultstring'))
|
||||||
elif response.status_code != requests.codes.ACCEPTED:
|
elif response.status_code != requests.codes.ACCEPTED:
|
||||||
msg = 'Invalid status code: {0}'.format(response.status_code)
|
msg = 'Invalid status code: {0}'.format(response.status_code)
|
||||||
|
@@ -90,8 +90,7 @@ class TestBaseIronicPythonAgent(test_base.BaseTestCase):
|
|||||||
advertise_address=('192.0.2.1', '9999'))
|
advertise_address=('192.0.2.1', '9999'))
|
||||||
|
|
||||||
def test_heartbeat_409_status_code(self):
|
def test_heartbeat_409_status_code(self):
|
||||||
response = mock.Mock()
|
response = FakeResponse(status_code=409)
|
||||||
response.status_code = 409
|
|
||||||
self.api_client.session.request = mock.Mock()
|
self.api_client.session.request = mock.Mock()
|
||||||
self.api_client.session.request.return_value = response
|
self.api_client.session.request.return_value = response
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user