summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openstack/common/rpc/__init__.py2
-rw-r--r--tests/unit/rpc/test_common.py4
2 files changed, 5 insertions, 1 deletions
diff --git a/openstack/common/rpc/__init__.py b/openstack/common/rpc/__init__.py
index da45d5a..f84c493 100644
--- a/openstack/common/rpc/__init__.py
+++ b/openstack/common/rpc/__init__.py
@@ -250,7 +250,7 @@ def queue_get_for(context, topic, host):
Messages sent to the 'foo.<host>' topic are sent to the nova-foo service on
<host>.
"""
- return '%s.%s' % (topic, host)
+ return '%s.%s' % (topic, host) if host else topic
_RPCIMPL = None
diff --git a/tests/unit/rpc/test_common.py b/tests/unit/rpc/test_common.py
index 2066a64..80b717b 100644
--- a/tests/unit/rpc/test_common.py
+++ b/tests/unit/rpc/test_common.py
@@ -167,3 +167,7 @@ class RpcCommonTestCase(test_utils.BaseTestCase):
importutils.import_module = orig_import_module
self.assertEqual(self.mod, 'nova.openstack.common.rpc.impl_qpid')
+
+ def test_queue_get_for(self):
+ self.assertEqual(rpc.queue_get_for(None, 'a', 'b'), 'a.b')
+ self.assertEqual(rpc.queue_get_for(None, 'a', None), 'a')