diff options
author | Russell Bryant <rbryant@redhat.com> | 2012-06-13 09:47:21 -0400 |
---|---|---|
committer | Russell Bryant <rbryant@redhat.com> | 2012-06-13 10:02:41 -0400 |
commit | 91fc479399ab12d8ba670c3627582ebfc3950af8 (patch) | |
tree | 56a7308acbf7a7bb732ccf60af1268cbce1e9baa /openstack/common/rpc/__init__.py | |
parent | 341ae3b475f9aab85c9202995529b1d041a71b2b (diff) | |
download | oslo-91fc479399ab12d8ba670c3627582ebfc3950af8.tar.gz oslo-91fc479399ab12d8ba670c3627582ebfc3950af8.tar.xz oslo-91fc479399ab12d8ba670c3627582ebfc3950af8.zip |
rpc: Update rpc_backend handling.
Part of blueprint common-rpc.
This patch updates the rpc_backend option handling in a couple of ways.
1) Set the default based on wherever this code has been copied to.
2) If we fail to import the backend, replace 'nova.rpc' with
'nova.openstack.common.rpc' just in case the value came from an older
nova configuration file. Backwards compatibility is a good thing.
Change-Id: I9ad7c084a2f0813ca1559115e7612f0a24fcce67
Diffstat (limited to 'openstack/common/rpc/__init__.py')
-rw-r--r-- | openstack/common/rpc/__init__.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/openstack/common/rpc/__init__.py b/openstack/common/rpc/__init__.py index 26bd048..169aeca 100644 --- a/openstack/common/rpc/__init__.py +++ b/openstack/common/rpc/__init__.py @@ -31,7 +31,7 @@ from openstack.common import importutils rpc_opts = [ cfg.StrOpt('rpc_backend', - default='nova.rpc.impl_kombu', + default='%s.impl_kombu' % __package__, help="The messaging module to use, defaults to kombu."), cfg.IntOpt('rpc_thread_pool_size', default=64, @@ -248,5 +248,11 @@ def _get_impl(): """Delay import of rpc_backend until configuration is loaded.""" global _RPCIMPL if _RPCIMPL is None: - _RPCIMPL = importutils.import_module(cfg.CONF.rpc_backend) + try: + _RPCIMPL = importutils.import_module(cfg.CONF.rpc_backend) + except ImportError: + # For backwards compatibility with older nova config. + impl = cfg.CONF.rpc_backend.replace('nova.rpc', + 'nova.openstack.common.rpc') + _RPCIMPL = importutils.import_module(impl) return _RPCIMPL |