summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorRussell Bryant <rbryant@redhat.com>2012-05-15 14:43:18 -0400
committerRussell Bryant <rbryant@redhat.com>2012-05-15 15:44:14 -0400
commit5de77cad7104cff71ce9191296448d3fe50d08c8 (patch)
treeabf4e8665aa1773ce181101c684fcca82ee328b9 /nova
parentba76b954e69de56f76f9db5cade1780bc351be67 (diff)
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
Diffstat (limited to 'nova')
-rw-r--r--nova/exception.py4
-rw-r--r--nova/rpc/amqp.py4
-rw-r--r--nova/rpc/common.py31
3 files changed, 29 insertions, 10 deletions
diff --git a/nova/exception.py b/nova/exception.py
index c1d02faaa..af4850367 100644
--- a/nova/exception.py
+++ b/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.")
diff --git a/nova/rpc/amqp.py b/nova/rpc/amqp.py
index 798a5f36e..b0a0d5d12 100644
--- a/nova/rpc/amqp.py
+++ b/nova/rpc/amqp.py
@@ -34,7 +34,6 @@ from eventlet import pools
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 @@ class ConnectionContext(rpc_common.Connection):
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 @@ class ProxyCallback(object):
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.
diff --git a/nova/rpc/common.py b/nova/rpc/common.py
index 23a191a9b..d15d1f3f1 100644
--- a/nova/rpc/common.py
+++ b/nova/rpc/common.py
@@ -21,7 +21,6 @@ import copy
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 @@ from nova.openstack.common import jsonutils
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 @@ class RemoteError(exception.NovaException):
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().