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:
Lucas Alvares Gomes
2016-03-11 16:54:52 +00:00
parent 944dc4e248
commit f09dce79af
2 changed files with 2 additions and 3 deletions

View File

@@ -73,7 +73,7 @@ class APIClient(object):
raise errors.HeartbeatError(str(e))
if response.status_code == requests.codes.CONFLICT:
data = response.json
data = json.loads(response.content)
raise errors.HeartbeatConflictError(data.get('faultstring'))
elif response.status_code != requests.codes.ACCEPTED:
msg = 'Invalid status code: {0}'.format(response.status_code)

View File

@@ -90,8 +90,7 @@ class TestBaseIronicPythonAgent(test_base.BaseTestCase):
advertise_address=('192.0.2.1', '9999'))
def test_heartbeat_409_status_code(self):
response = mock.Mock()
response.status_code = 409
response = FakeResponse(status_code=409)
self.api_client.session.request = mock.Mock()
self.api_client.session.request.return_value = response