diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-02-11 02:31:30 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-02-11 02:31:30 +0000 |
| commit | 9c727b28e83f08dcd7d247546557af54428c2417 (patch) | |
| tree | cefe6493d98de6ead4ca6f56fabc4e2efc718cb7 /openstack | |
| parent | 1febfc8132131f5961707b707324e6ff53bebf34 (diff) | |
| parent | 4a1ec2169d0a75afffc61437735dfb3959530bc5 (diff) | |
| download | oslo-9c727b28e83f08dcd7d247546557af54428c2417.tar.gz oslo-9c727b28e83f08dcd7d247546557af54428c2417.tar.xz oslo-9c727b28e83f08dcd7d247546557af54428c2417.zip | |
Merge "Support testing args for LocalhostMatchMaker."
Diffstat (limited to 'openstack')
| -rw-r--r-- | openstack/common/rpc/impl_zmq.py | 5 | ||||
| -rw-r--r-- | openstack/common/rpc/matchmaker.py | 11 |
2 files changed, 9 insertions, 7 deletions
diff --git a/openstack/common/rpc/impl_zmq.py b/openstack/common/rpc/impl_zmq.py index cd974e5..01114bc 100644 --- a/openstack/common/rpc/impl_zmq.py +++ b/openstack/common/rpc/impl_zmq.py @@ -772,8 +772,9 @@ def _get_ctxt(): return ZMQ_CTX -def _get_matchmaker(): +def _get_matchmaker(*args, **kwargs): global matchmaker if not matchmaker: - matchmaker = importutils.import_object(CONF.rpc_zmq_matchmaker) + matchmaker = importutils.import_object( + CONF.rpc_zmq_matchmaker, *args, **kwargs) return matchmaker diff --git a/openstack/common/rpc/matchmaker.py b/openstack/common/rpc/matchmaker.py index d68799b..07190f0 100644 --- a/openstack/common/rpc/matchmaker.py +++ b/openstack/common/rpc/matchmaker.py @@ -201,11 +201,12 @@ class FanoutRingExchange(RingExchange): class LocalhostExchange(Exchange): """Exchange where all direct topics are local.""" - def __init__(self): + def __init__(self, host='localhost'): + self.host = host super(Exchange, self).__init__() def run(self, key): - return [(key.split('.')[0] + '.localhost', 'localhost')] + return [('.'.join((key.split('.')[0], self.host)), self.host)] class DirectExchange(Exchange): @@ -237,11 +238,11 @@ class MatchMakerLocalhost(MatchMakerBase): Match Maker where all bare topics resolve to localhost. Useful for testing. """ - def __init__(self): + def __init__(self, host='localhost'): super(MatchMakerLocalhost, self).__init__() - self.add_binding(FanoutBinding(), LocalhostExchange()) + self.add_binding(FanoutBinding(), LocalhostExchange(host)) self.add_binding(DirectBinding(), DirectExchange()) - self.add_binding(TopicBinding(), LocalhostExchange()) + self.add_binding(TopicBinding(), LocalhostExchange(host)) class MatchMakerStub(MatchMakerBase): |
