Merge "Properly handle transport:///vhost URL"

This commit is contained in:
Jenkins 2013-10-24 01:14:51 +00:00 committed by Gerrit Code Review
commit 18a11da1dc
2 changed files with 18 additions and 14 deletions
oslo/messaging/_drivers
tests

@ -291,21 +291,20 @@ class AMQPDriverBase(base.BaseDriver):
self._waiter = None
def _server_params_from_url(self, url):
if not url.hosts:
return None
sp = {}
sp = {
'virtual_host': url.virtual_host,
}
if url.virtual_host is not None:
sp['virtual_host'] = url.virtual_host
# FIXME(markmc): support multiple hosts
host = url.hosts[0]
if url.hosts:
# FIXME(markmc): support multiple hosts
host = url.hosts[0]
sp['hostname'] = host.hostname
if host.port is not None:
sp['port'] = host.port
sp['username'] = host.username or ''
sp['password'] = host.password or ''
sp['hostname'] = host.hostname
if host.port is not None:
sp['port'] = host.port
sp['username'] = host.username or ''
sp['password'] = host.password or ''
return sp

@ -48,14 +48,19 @@ class TestRabbitDriverLoad(test_utils.BaseTestCase):
class TestRabbitTransportURL(test_utils.BaseTestCase):
scenarios = [
('none', dict(url=None, expected=None)),
('empty', dict(url='rabbit:///', expected=None)),
('none', dict(url=None, expected={})),
('empty',
dict(url='rabbit:///',
expected=dict(virtual_host=''))),
('localhost',
dict(url='rabbit://localhost/',
expected=dict(hostname='localhost',
username='',
password='',
virtual_host=''))),
('virtual_host',
dict(url='rabbit:///vhost',
expected=dict(virtual_host='vhost'))),
('no_creds',
dict(url='rabbit://host/virtual_host',
expected=dict(hostname='host',