From 4a1ec2169d0a75afffc61437735dfb3959530bc5 Mon Sep 17 00:00:00 2001 From: Eric Windisch Date: Fri, 1 Feb 2013 11:08:37 -0500 Subject: 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 --- openstack/common/rpc/matchmaker.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'openstack/common/rpc/matchmaker.py') 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): -- cgit