summaryrefslogtreecommitdiffstats
path: root/openstack
diff options
context:
space:
mode:
authorChris Behrens <cbehrens@codestud.com>2013-05-20 22:14:31 +0000
committerChris Behrens <cbehrens@codestud.com>2013-05-20 22:14:31 +0000
commitdf7ea8308363235afba503f8562341bd2e3dce4f (patch)
tree68fd667af50830e89a44de39db9dacfaa99eeafa /openstack
parent97bb81ddbcc47343c78e0a6efe724878fcb35ecb (diff)
downloadoslo-df7ea8308363235afba503f8562341bd2e3dce4f.tar.gz
oslo-df7ea8308363235afba503f8562341bd2e3dce4f.tar.xz
oslo-df7ea8308363235afba503f8562341bd2e3dce4f.zip
Allow RPC_API_NAMESPACE on RpcProxy objects
This allows one to subclass RpcProxy for use with a particular namespace without having to repeatedly pass the namespace into the make_namespaced_msg() method. This new RPC_API_NAMESPACE attribute will be used for the make_msg() call. It is defaulted to None to match previous behavior. Change-Id: Ied62df839cda0be6f9f9b060bbfc22e086f61be8
Diffstat (limited to 'openstack')
-rw-r--r--openstack/common/rpc/proxy.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/openstack/common/rpc/proxy.py b/openstack/common/rpc/proxy.py
index 0b311de..0fb140f 100644
--- a/openstack/common/rpc/proxy.py
+++ b/openstack/common/rpc/proxy.py
@@ -35,6 +35,9 @@ class RpcProxy(object):
rpc API.
"""
+ # The default namespace, which can be overriden in a subclass.
+ RPC_API_NAMESPACE = None
+
def __init__(self, topic, default_version, version_cap=None):
"""Initialize an RpcProxy.
@@ -70,9 +73,9 @@ class RpcProxy(object):
def make_namespaced_msg(method, namespace, **kwargs):
return {'method': method, 'namespace': namespace, 'args': kwargs}
- @staticmethod
- def make_msg(method, **kwargs):
- return RpcProxy.make_namespaced_msg(method, None, **kwargs)
+ def make_msg(self, method, **kwargs):
+ return self.make_namespaced_msg(method, self.RPC_API_NAMESPACE,
+ **kwargs)
def call(self, context, msg, topic=None, version=None, timeout=None):
"""rpc.call() a remote method.