From ff1133c8ba649d6bfe2af6abc68bf42ebb68831e Mon Sep 17 00:00:00 2001 From: ericxiett Date: Thu, 9 Feb 2017 16:55:11 +0800 Subject: [PATCH] Fix improper prompt when update RC with existed one's name. When update resource class with existed one's name, the exception message was formatted by the updated resource class's name, rather than the required existed one's name. This patch formats the message with existed one's name, and changing tests to add the right name. Change-Id: I78ae8d872748de243d74b9954ce634fccf5e7310 Closes-Bug: #1663163 --- nova/api/openstack/placement/handlers/resource_class.py | 2 +- .../api/openstack/placement/gabbits/resource-classes.yaml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/nova/api/openstack/placement/handlers/resource_class.py b/nova/api/openstack/placement/handlers/resource_class.py index affdd0f31b98..af0c8cd96c5f 100644 --- a/nova/api/openstack/placement/handlers/resource_class.py +++ b/nova/api/openstack/placement/handlers/resource_class.py @@ -183,7 +183,7 @@ def update_resource_class(req): except exception.ResourceClassExists: raise webob.exc.HTTPConflict( _('Resource class already exists: %(name)s') % - {'name': name}, + {'name': rc.name}, json_formatter=util.json_error_formatter) except exception.ResourceClassCannotUpdateStandard: raise webob.exc.HTTPBadRequest( diff --git a/nova/tests/functional/api/openstack/placement/gabbits/resource-classes.yaml b/nova/tests/functional/api/openstack/placement/gabbits/resource-classes.yaml index fda14a4860cd..6c3c37e9b368 100644 --- a/nova/tests/functional/api/openstack/placement/gabbits/resource-classes.yaml +++ b/nova/tests/functional/api/openstack/placement/gabbits/resource-classes.yaml @@ -151,6 +151,7 @@ tests: status: 409 response_strings: - Resource class already exists + - $ENVIRON['CUSTOM_RES_CLASS'] - name: update custom resource class PUT: /resource_classes/$ENVIRON['CUSTOM_RES_CLASS']