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.")
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
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,
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.
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
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,
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
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().