Stop using cinder.exception from cinder.rpc.

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

One other change that should be reviewed closely is the removal of using
cinder.exception.wrap_exception() in cinder.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
Reviewed-on: https://review.openstack.org/9899
Reviewed-by: Vish Ishaya <vishvananda@gmail.com>
Approved: John Griffith <john.griffith@solidfire.com>
Tested-by: Jenkins
This commit is contained in:
Russell Bryant
2012-05-15 14:43:18 -04:00
committed by Jenkins
parent 4ab214a35f
commit 9e4242c386
3 changed files with 29 additions and 10 deletions

View File

@@ -270,10 +270,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 File

@@ -34,7 +34,6 @@ from eventlet import pools
from eventlet import semaphore
from cinder import context
from cinder import exception
from cinder import log as logging
from cinder.openstack.common import local
import cinder.rpc.common as rpc_common
@@ -140,7 +139,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,
@@ -249,7 +248,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.

View File

@@ -21,7 +21,6 @@ import copy
import sys
import traceback
from cinder import exception
from cinder import log as logging
from cinder.openstack.common import cfg
from cinder.openstack.common import importutils
@@ -31,7 +30,29 @@ from cinder import utils
LOG = logging.getLogger(__name__)
class RemoteError(exception.CinderException):
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.CinderException):
traceback=traceback)
class Timeout(exception.CinderException):
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.CinderException):
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().