From 8a9c7a11e008fde92905be1d1183da1b3f3f184c Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Wed, 21 Aug 2013 14:09:31 +0100 Subject: [PATCH] Fix incorrect use of ServerError ServerError is being incorrectly used to report an internal error leading to an error formatting the response, as there's no body specified to the format string. Use exception.Error instead and adjust the message to make the user-visible response clearer. Fixes bug #1214457 Change-Id: I83435686170c4f40658968a35f1faa303f50f4a4 --- heat/engine/parser.py | 3 +-- heat/engine/resources/nova_utils.py | 3 ++- heat/tests/test_validate.py | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/heat/engine/parser.py b/heat/engine/parser.py index 56a60b6b..469366de 100644 --- a/heat/engine/parser.py +++ b/heat/engine/parser.py @@ -34,7 +34,6 @@ from heat.db import api as db_api from heat.openstack.common import log as logging from heat.openstack.common.gettextutils import _ -from heat.common.exception import ServerError from heat.common.exception import StackValidationFailed logger = logging.getLogger(__name__) @@ -259,7 +258,7 @@ class Stack(object): for res in self: try: result = res.validate() - except ServerError as ex: + except exception.Error as ex: logger.exception(ex) raise ex except Exception as ex: diff --git a/heat/engine/resources/nova_utils.py b/heat/engine/resources/nova_utils.py index daf4d770..1e30a625 100644 --- a/heat/engine/resources/nova_utils.py +++ b/heat/engine/resources/nova_utils.py @@ -66,7 +66,8 @@ def get_image_id(nova_client, image_identifier): try: image_list = nova_client.images.list() except clients.novaclient.exceptions.ClientException as ex: - raise exception.ServerError(message=str(ex)) + raise exception.Error( + message="Error retrieving image list from nova: %s" % str(ex)) image_names = dict( (o.id, o.name) for o in image_list if o.name == image_identifier) diff --git a/heat/tests/test_validate.py b/heat/tests/test_validate.py index 12b424a6..e681c0cb 100644 --- a/heat/tests/test_validate.py +++ b/heat/tests/test_validate.py @@ -817,8 +817,7 @@ class validateTest(HeatTestCase): instances.Instance.nova().AndReturn(self.fc) self.m.ReplayAll() - self.assertRaises(exception.ServerError, - stack.validate) + self.assertRaises(exception.Error, stack.validate) self.m.VerifyAll() def test_validate_unique_logical_name(self): -- 2.45.2