From 91fc479399ab12d8ba670c3627582ebfc3950af8 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Wed, 13 Jun 2012 09:47:21 -0400 Subject: 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 --- openstack/common/rpc/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'openstack') 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 -- cgit