summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-06-11 21:40:11 +0000
committerGerrit Code Review <review@openstack.org>2013-06-11 21:40:11 +0000
commit36d967b6380ea7cc066e362c5525de767356000e (patch)
tree4ab71e567ad246bddea6743c53618b7c11fbcb0e
parent507f85183006942ddca30b38d69116d3ff6118fe (diff)
parent80476f0c6e70e23102495e383e98ae0e912e07f6 (diff)
downloadoslo-36d967b6380ea7cc066e362c5525de767356000e.tar.gz
oslo-36d967b6380ea7cc066e362c5525de767356000e.tar.xz
oslo-36d967b6380ea7cc066e362c5525de767356000e.zip
Merge "Add can_send_version() to RpcProxy."
-rw-r--r--openstack/common/rpc/proxy.py5
-rw-r--r--tests/unit/rpc/test_proxy.py10
2 files changed, 15 insertions, 0 deletions
diff --git a/openstack/common/rpc/proxy.py b/openstack/common/rpc/proxy.py
index 3b74fe1..8523421 100644
--- a/openstack/common/rpc/proxy.py
+++ b/openstack/common/rpc/proxy.py
@@ -76,6 +76,11 @@ class RpcProxy(object):
"""Return the topic to use for a message."""
return topic if topic else self.topic
+ def can_send_version(self, version):
+ """Check to see if a version is compatible with the version cap."""
+ return (not self.version_cap or
+ rpc_common.version_is_compatible(self.version_cap, version))
+
@staticmethod
def make_namespaced_msg(method, namespace, **kwargs):
return {'method': method, 'namespace': namespace, 'args': kwargs}
diff --git a/tests/unit/rpc/test_proxy.py b/tests/unit/rpc/test_proxy.py
index 9427cbe..9f67c83 100644
--- a/tests/unit/rpc/test_proxy.py
+++ b/tests/unit/rpc/test_proxy.py
@@ -209,3 +209,13 @@ class RpcProxyTestCase(utils.BaseTestCase):
msg = rpc_proxy.make_msg('foo', a=1, b=2)
result = rpc_proxy.call(ctxt, msg)
self.assertEqual(result, 'worked!')
+
+ def test_can_send_version(self):
+ proxy_obj = proxy.RpcProxy('fake', '1.0', version_cap='1.5')
+ self.assertTrue(proxy_obj.can_send_version('1.5'))
+ self.assertFalse(proxy_obj.can_send_version('1.6'))
+
+ def test_can_send_version_with_no_cap(self):
+ proxy_obj = proxy.RpcProxy('fake', '1.0')
+ self.assertTrue(proxy_obj.can_send_version('1.5'))
+ self.assertTrue(proxy_obj.can_send_version('1.99'))