From c1d78cc4f8f4467b8c9ef59b0db2153fe095da09 Mon Sep 17 00:00:00 2001 From: Hans Lindgren Date: Tue, 19 Mar 2013 21:33:21 +0100 Subject: List InstanceNotFound as a client exception get_instance_nw_info() in nova.network.manager should list InstanceNotFound as a client exception for rpc. This to prevent the rpc layer from logging a traceback when this exception is raised. This is an expected type of exception that should be left to the client to handle. Resolves bug 1157411. Change-Id: I6735fb8a386f2256ac8af0ce7fdb36ef7a00b6ce --- nova/network/manager.py | 2 ++ nova/tests/network/test_manager.py | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/nova/network/manager.py b/nova/network/manager.py index 678bfdba8..b9c8efe44 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -67,6 +67,7 @@ from nova.openstack.common import importutils from nova.openstack.common import jsonutils from nova.openstack.common import lockutils from nova.openstack.common import log as logging +from nova.openstack.common.rpc import common as rpc_common from nova.openstack.common import timeutils from nova.openstack.common import uuidutils from nova import quota @@ -557,6 +558,7 @@ class NetworkManager(manager.Manager): self.db.virtual_interface_delete_by_instance(read_deleted_context, instance_uuid) + @rpc_common.client_exceptions(exception.InstanceNotFound) def get_instance_nw_info(self, context, instance_id, rxtx_factor, host, instance_uuid=None, **kwargs): """Creates network info list for instance. diff --git a/nova/tests/network/test_manager.py b/nova/tests/network/test_manager.py index 2fe53968b..c4ce649f0 100644 --- a/nova/tests/network/test_manager.py +++ b/nova/tests/network/test_manager.py @@ -1222,6 +1222,18 @@ class CommonNetworkTestCase(test.TestCase): def fake_create_fixed_ips(self, context, network_id, fixed_cidr=None): return None + def test_get_instance_nw_info_client_exceptions(self): + manager = network_manager.NetworkManager() + self.mox.StubOutWithMock(manager.db, + 'virtual_interface_get_by_instance') + manager.db.virtual_interface_get_by_instance( + self.context, FAKEUUID).AndRaise(exception.InstanceNotFound( + instance_id=FAKEUUID)) + self.mox.ReplayAll() + self.assertRaises(rpc_common.ClientException, + manager.get_instance_nw_info, + self.context, FAKEUUID, 'fake_rxtx_factor', HOST) + def test_deallocate_for_instance_passes_host_info(self): manager = fake_network.FakeNetworkManager() db = manager.db -- cgit