summaryrefslogtreecommitdiffstats
path: root/openstack/common/rpc/impl_fake.py
diff options
context:
space:
mode:
authorRussell Bryant <rbryant@redhat.com>2013-03-30 01:05:12 -0400
committerRussell Bryant <rbryant@redhat.com>2013-04-12 10:42:50 -0400
commit6901a3ba3e09ae091480b650ec23c2f2d9543152 (patch)
tree34062944991e1611b1f66965da7f1870fc1589fd /openstack/common/rpc/impl_fake.py
parent9dcf688ea80f52cdb5413514198b2aa81d5a4e09 (diff)
downloadoslo-6901a3ba3e09ae091480b650ec23c2f2d9543152.tar.gz
oslo-6901a3ba3e09ae091480b650ec23c2f2d9543152.tar.xz
oslo-6901a3ba3e09ae091480b650ec23c2f2d9543152.zip
Add rpc method namespace support.
RPC endpoints already had the ability to expose multiple APIs ... sort of. You could pass multiple callback objects to the dispatcher and it would check all of them for a method call. This patch adds the ability to set a namespace on a callback object. This makes exposing multiple APIs a bit more like you would expect it to work. You can invoke a method on a specific callback object, as opposed to having it check all of them for the method. This will allow you to create, manage, and version APIs without any potential conflicts with other APIs being exposed by the same endpoint. An example of where I would like to use this is in Nova, where we have some methods that we would like to expose on *all* rpc endpoints. This includes no public API changes and is fully backwards compatible. Implement blueprint rpc-multi-api. Change-Id: Ief4433e2e1c32cfb05b4cd27b87fe32b40f4341d
Diffstat (limited to 'openstack/common/rpc/impl_fake.py')
-rw-r--r--openstack/common/rpc/impl_fake.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/openstack/common/rpc/impl_fake.py b/openstack/common/rpc/impl_fake.py
index 1086147..815570d 100644
--- a/openstack/common/rpc/impl_fake.py
+++ b/openstack/common/rpc/impl_fake.py
@@ -57,13 +57,14 @@ class Consumer(object):
self.topic = topic
self.proxy = proxy
- def call(self, context, version, method, args, timeout):
+ def call(self, context, version, method, namespace, args, timeout):
done = eventlet.event.Event()
def _inner():
ctxt = RpcContext.from_dict(context.to_dict())
try:
- rval = self.proxy.dispatch(context, version, method, **args)
+ rval = self.proxy.dispatch(context, version, method,
+ namespace, **args)
res = []
# Caller might have called ctxt.reply() manually
for (reply, failure) in ctxt._response:
@@ -140,13 +141,15 @@ def multicall(conf, context, topic, msg, timeout=None):
return
args = msg.get('args', {})
version = msg.get('version', None)
+ namespace = msg.get('namespace', None)
try:
consumer = CONSUMERS[topic][0]
except (KeyError, IndexError):
return iter([None])
else:
- return consumer.call(context, version, method, args, timeout)
+ return consumer.call(context, version, method, namespace, args,
+ timeout)
def call(conf, context, topic, msg, timeout=None):
@@ -183,9 +186,10 @@ def fanout_cast(conf, context, topic, msg):
return
args = msg.get('args', {})
version = msg.get('version', None)
+ namespace = msg.get('namespace', None)
for consumer in CONSUMERS.get(topic, []):
try:
- consumer.call(context, version, method, args, None)
+ consumer.call(context, version, method, namespace, args, None)
except Exception:
pass