Skip to content
Browse files

Stop using nova.exception from nova.rpc.

This patch is a part of continuing to remove dependencies from nova.rpc
on the rest of nova.  One RPC related exception was defined in
nova.exception, so that was moved to nova.rpc.common where the rest of
them live.  These exceptions were changed to no longer use NovaException
as their base.  Instead, there is a new RPCException base.

One other change that should be reviewed closely is the removal of using
nova.exception.wrap_exception() in nova.rpc.amqp.  As far as I can tell,
this didn't actually do anything since nothing was being passed in to
wrap_exception().

Change-Id: I36ff7c05ab0467ad8506b56d561c532eadf8dff8
  • Loading branch information...
1 parent ba76b95 commit 5de77cad7104cff71ce9191296448d3fe50d08c8 @russellb russellb committed May 15, 2012
Showing with 29 additions and 10 deletions.
  1. +0 −4 nova/exception.py
  2. +1 −3 nova/rpc/amqp.py
  3. +28 −3 nova/rpc/common.py
View
4 nova/exception.py
@@ -282,10 +282,6 @@ class InvalidCidr(Invalid):
message = _("Invalid cidr %(cidr)s.")
-class InvalidRPCConnectionReuse(Invalid):
- message = _("Invalid reuse of an RPC connection.")
-
-
class InvalidUnicodeParameter(Invalid):
message = _("Invalid Parameter: "
"Unicode is not supported by the current database.")
View
4 nova/rpc/amqp.py
@@ -34,7 +34,6 @@
from eventlet import semaphore
from nova import context
-from nova import exception
from nova import log as logging
from nova.openstack.common import excutils
from nova.openstack.common import local
@@ -141,7 +140,7 @@ def __getattr__(self, key):
if self.connection:
return getattr(self.connection, key)
else:
- raise exception.InvalidRPCConnectionReuse()
+ raise rpc_common.InvalidRPCConnectionReuse()
def msg_reply(conf, msg_id, connection_pool, reply=None, failure=None,
@@ -250,7 +249,6 @@ def __call__(self, message_data):
return
self.pool.spawn_n(self._process_data, ctxt, method, args)
- @exception.wrap_exception()
def _process_data(self, ctxt, method, args):
"""Thread that magically looks for a method on the proxy
object and calls it.
View
31 nova/rpc/common.py
@@ -21,7 +21,6 @@
import sys
import traceback
-from nova import exception
from nova import log as logging
from nova.openstack.common import cfg
from nova.openstack.common import importutils
@@ -31,7 +30,29 @@
LOG = logging.getLogger(__name__)
-class RemoteError(exception.NovaException):
+class RPCException(Exception):
+ message = _("An unknown RPC related exception occurred.")
+
+ def __init__(self, message=None, **kwargs):
+ self.kwargs = kwargs
+
+ if not message:
+ try:
+ message = self.message % kwargs
+
+ except Exception as e:
+ # kwargs doesn't match a variable in the message
+ # log the issue and the kwargs
+ LOG.exception(_('Exception in string format operation'))
+ for name, value in kwargs.iteritems():
+ LOG.error("%s: %s" % (name, value))
+ # at least get the core message out if something happened
+ message = self.message
+
+ super(RPCException, self).__init__(message)
+
+
+class RemoteError(RPCException):
"""Signifies that a remote class has raised an exception.
Contains a string representation of the type of the original exception,
@@ -51,7 +72,7 @@ def __init__(self, exc_type=None, value=None, traceback=None):
traceback=traceback)
-class Timeout(exception.NovaException):
+class Timeout(RPCException):
"""Signifies that a timeout has occurred.
This exception is raised if the rpc_response_timeout is reached while
@@ -60,6 +81,10 @@ class Timeout(exception.NovaException):
message = _("Timeout while waiting on RPC response.")
+class InvalidRPCConnectionReuse(RPCException):
+ message = _("Invalid reuse of an RPC connection.")
+
+
class Connection(object):
"""A connection, returned by rpc.create_connection().

0 comments on commit 5de77ca

Please sign in to comment.
Something went wrong with that request. Please try again.