From 3aace2a610d8b5e7027ef141970e23cddba0294d Mon Sep 17 00:00:00 2001 From: Devananda van der Veen Date: Thu, 21 Feb 2013 13:56:25 -0800 Subject: Fix exception handling in baremetal API. In patch ab9f8667c63d901f37d1662c5204fb2938be44fe, several baremetal/db/api methods' exceptions were changed from InstanceNotFound to NodeNotFound. The API extension for baremetal was not updated to catch these, and this was not caught by unit testing. This resulted in unhandled exceptions within nova-api if any baremetal node lacked an associated interface. While fixing that bug, a few other unit tests for the baremetal API were added, and a missing exception was added to db/api bm_node_destroy. Fixes bug 1131430. Change-Id: I15f7624723754f9d7b217b609663a2d709acb056 --- nova/api/openstack/compute/contrib/baremetal_nodes.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'nova/api') diff --git a/nova/api/openstack/compute/contrib/baremetal_nodes.py b/nova/api/openstack/compute/contrib/baremetal_nodes.py index 38d66d2ae..70bb6e8a0 100644 --- a/nova/api/openstack/compute/contrib/baremetal_nodes.py +++ b/nova/api/openstack/compute/contrib/baremetal_nodes.py @@ -104,7 +104,7 @@ class BareMetalNodeController(wsgi.Controller): try: ifs = db.bm_interface_get_all_by_bm_node_id( context, node_from_db['id']) - except exception.InstanceNotFound: + except exception.NodeNotFound: ifs = [] node = _node_dict(node_from_db) node['interfaces'] = [_interface_dict(i) for i in ifs] @@ -117,11 +117,11 @@ class BareMetalNodeController(wsgi.Controller): authorize(context) try: node = db.bm_node_get(context, id) - except exception.InstanceNotFound: + except exception.NodeNotFound: raise webob.exc.HTTPNotFound try: ifs = db.bm_interface_get_all_by_bm_node_id(context, id) - except exception.InstanceNotFound: + except exception.NodeNotFound: ifs = [] node = _node_dict(node) node['interfaces'] = [_interface_dict(i) for i in ifs] @@ -141,14 +141,14 @@ class BareMetalNodeController(wsgi.Controller): authorize(context) try: db.bm_node_destroy(context, id) - except exception.InstanceNotFound: + except exception.NodeNotFound: raise webob.exc.HTTPNotFound return webob.Response(status_int=202) def _check_node_exists(self, context, node_id): try: db.bm_node_get(context, node_id) - except exception.InstanceNotFound: + except exception.NodeNotFound: raise webob.exc.HTTPNotFound @wsgi.serializers(xml=InterfaceTemplate) -- cgit