diff options
author | Eric Windisch <eric@cloudscaling.com> | 2013-02-01 11:08:37 -0500 |
---|---|---|
committer | Eric Windisch <eric@cloudscaling.com> | 2013-02-10 09:43:54 -0500 |
commit | 4a1ec2169d0a75afffc61437735dfb3959530bc5 (patch) | |
tree | b92b5b3181e613a2d1d6707a680988bbd3e3de35 /openstack/common/rpc/matchmaker.py | |
parent | bd5d9f08ecc3c1fade6dce809ee9edef1c226e54 (diff) | |
download | oslo-4a1ec2169d0a75afffc61437735dfb3959530bc5.tar.gz oslo-4a1ec2169d0a75afffc61437735dfb3959530bc5.tar.xz oslo-4a1ec2169d0a75afffc61437735dfb3959530bc5.zip |
Support testing args for LocalhostMatchMaker.
The matchmaker should return the correct
direct topics used by the RPC driver. The
LocalhostMatchMaker was always returning
'localhost', even though our tests might
use '127.0.0.1' instead. Now, the
LocalhostMatchmaker will use whatever
value it is told should be considered local.
MatchMakerLocalhost and LocalhostExchange
now take an optional host parameter.
impl_zmq._get_matchmaker now passes arguments to
the selected matchmaker module.
The test_zmq now initializes the matchmaker, using
the host '127.0.0.1'
Change-Id: I8daa2c0668f1d717eb95ab56009612b8b60f0a15
Diffstat (limited to 'openstack/common/rpc/matchmaker.py')
-rw-r--r-- | openstack/common/rpc/matchmaker.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/openstack/common/rpc/matchmaker.py b/openstack/common/rpc/matchmaker.py index 48270ba..2fcea64 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): |