diff --git a/novaclient/exceptions.py b/novaclient/exceptions.py index 727638bdc..b04844a2d 100644 --- a/novaclient/exceptions.py +++ b/novaclient/exceptions.py @@ -206,7 +206,7 @@ def from_response(response, body, url, method=None): details = "n/a" if hasattr(body, 'keys'): - error = body[body.keys()[0]] + error = body[list(body)[0]] message = error.get('message', None) details = error.get('details', None) diff --git a/novaclient/tests/v1_1/contrib/fakes.py b/novaclient/tests/v1_1/contrib/fakes.py index b9e79e841..1d679f352 100644 --- a/novaclient/tests/v1_1/contrib/fakes.py +++ b/novaclient/tests/v1_1/contrib/fakes.py @@ -113,7 +113,7 @@ class FakeHTTPClient(fakes.FakeHTTPClient): def post_os_baremetal_nodes_1_action(self, **kw): body = kw['body'] - action = body.keys()[0] + action = list(body)[0] if action == "add_interface": return ( 200, {}, { diff --git a/novaclient/tests/v1_1/fakes.py b/novaclient/tests/v1_1/fakes.py index 7b6bc119d..06cfce93d 100644 --- a/novaclient/tests/v1_1/fakes.py +++ b/novaclient/tests/v1_1/fakes.py @@ -488,7 +488,7 @@ class FakeHTTPClient(base_client.HTTPClient): _body = None resp = 202 assert len(body.keys()) == 1 - action = body.keys()[0] + action = list(body)[0] if action == 'reboot': assert body[action].keys() == ['type'] assert body[action]['type'] in ['HARD', 'SOFT']