Remove transport aliases support
To facilitate removing rpc_backend support, disentangle the aliases code by removing it to simplify the code and the tests. Aliases were first depreacted in 5.20.0 during Pike. Change-Id: I7d80cd050ce1eca2c6b6c38f0fac29d090b90bf3 Closes-Bug: #1424728
This commit is contained in:
parent
9e61ad5405
commit
e55f419017
@ -140,8 +140,7 @@ class Driver(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def get_notification_transport(conf, url=None,
|
def get_notification_transport(conf, url=None, allowed_remote_exmods=None):
|
||||||
allowed_remote_exmods=None, aliases=None):
|
|
||||||
"""A factory method for Transport objects for notifications.
|
"""A factory method for Transport objects for notifications.
|
||||||
|
|
||||||
This method should be used for notifications, in case notifications are
|
This method should be used for notifications, in case notifications are
|
||||||
@ -164,15 +163,13 @@ def get_notification_transport(conf, url=None,
|
|||||||
transport will deserialize remote exceptions
|
transport will deserialize remote exceptions
|
||||||
from
|
from
|
||||||
:type allowed_remote_exmods: list
|
:type allowed_remote_exmods: list
|
||||||
:param aliases: A map of transport alias to transport name
|
|
||||||
:type aliases: dict
|
|
||||||
"""
|
"""
|
||||||
conf.register_opts(_notifier_opts,
|
conf.register_opts(_notifier_opts,
|
||||||
group='oslo_messaging_notifications')
|
group='oslo_messaging_notifications')
|
||||||
if url is None:
|
if url is None:
|
||||||
url = conf.oslo_messaging_notifications.transport_url
|
url = conf.oslo_messaging_notifications.transport_url
|
||||||
return msg_transport._get_transport(
|
return msg_transport._get_transport(
|
||||||
conf, url, allowed_remote_exmods, aliases,
|
conf, url, allowed_remote_exmods,
|
||||||
transport_cls=msg_transport.NotificationTransport)
|
transport_cls=msg_transport.NotificationTransport)
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,63 +53,39 @@ class GetTransportTestCase(test_utils.BaseTestCase):
|
|||||||
scenarios = [
|
scenarios = [
|
||||||
('rpc_backend',
|
('rpc_backend',
|
||||||
dict(url=None, transport_url=None, rpc_backend='testbackend',
|
dict(url=None, transport_url=None, rpc_backend='testbackend',
|
||||||
control_exchange=None, allowed=None, aliases=None,
|
control_exchange=None, allowed=None,
|
||||||
expect=dict(backend='testbackend',
|
expect=dict(backend='testbackend',
|
||||||
exchange=None,
|
exchange=None,
|
||||||
url='testbackend:',
|
url='testbackend:',
|
||||||
allowed=[]))),
|
allowed=[]))),
|
||||||
('transport_url',
|
('transport_url',
|
||||||
dict(url=None, transport_url='testtransport:', rpc_backend=None,
|
dict(url=None, transport_url='testtransport:', rpc_backend=None,
|
||||||
control_exchange=None, allowed=None, aliases=None,
|
control_exchange=None, allowed=None,
|
||||||
expect=dict(backend='testtransport',
|
expect=dict(backend='testtransport',
|
||||||
exchange=None,
|
exchange=None,
|
||||||
url='testtransport:',
|
url='testtransport:',
|
||||||
allowed=[]))),
|
allowed=[]))),
|
||||||
('url_param',
|
('url_param',
|
||||||
dict(url='testtransport:', transport_url=None, rpc_backend=None,
|
dict(url='testtransport:', transport_url=None, rpc_backend=None,
|
||||||
control_exchange=None, allowed=None, aliases=None,
|
control_exchange=None, allowed=None,
|
||||||
expect=dict(backend='testtransport',
|
expect=dict(backend='testtransport',
|
||||||
exchange=None,
|
exchange=None,
|
||||||
url='testtransport:',
|
url='testtransport:',
|
||||||
allowed=[]))),
|
allowed=[]))),
|
||||||
('control_exchange',
|
('control_exchange',
|
||||||
dict(url=None, transport_url=None, rpc_backend='testbackend',
|
dict(url=None, transport_url=None, rpc_backend='testbackend',
|
||||||
control_exchange='testexchange', allowed=None, aliases=None,
|
control_exchange='testexchange', allowed=None,
|
||||||
expect=dict(backend='testbackend',
|
expect=dict(backend='testbackend',
|
||||||
exchange='testexchange',
|
exchange='testexchange',
|
||||||
url='testbackend:',
|
url='testbackend:',
|
||||||
allowed=[]))),
|
allowed=[]))),
|
||||||
('allowed_remote_exmods',
|
('allowed_remote_exmods',
|
||||||
dict(url=None, transport_url=None, rpc_backend='testbackend',
|
dict(url=None, transport_url=None, rpc_backend='testbackend',
|
||||||
control_exchange=None, allowed=['foo', 'bar'], aliases=None,
|
control_exchange=None, allowed=['foo', 'bar'],
|
||||||
expect=dict(backend='testbackend',
|
expect=dict(backend='testbackend',
|
||||||
exchange=None,
|
exchange=None,
|
||||||
url='testbackend:',
|
url='testbackend:',
|
||||||
allowed=['foo', 'bar']))),
|
allowed=['foo', 'bar']))),
|
||||||
('rpc_backend_aliased',
|
|
||||||
dict(url=None, transport_url=None, rpc_backend='testfoo',
|
|
||||||
control_exchange=None, allowed=None,
|
|
||||||
aliases=dict(testfoo='testbackend'),
|
|
||||||
expect=dict(backend='testbackend',
|
|
||||||
exchange=None,
|
|
||||||
url='testbackend:',
|
|
||||||
allowed=[]))),
|
|
||||||
('transport_url_aliased',
|
|
||||||
dict(url=None, transport_url='testfoo:', rpc_backend=None,
|
|
||||||
control_exchange=None, allowed=None,
|
|
||||||
aliases=dict(testfoo='testtransport'),
|
|
||||||
expect=dict(backend='testtransport',
|
|
||||||
exchange=None,
|
|
||||||
url='testtransport:',
|
|
||||||
allowed=[]))),
|
|
||||||
('url_param_aliased',
|
|
||||||
dict(url='testfoo:', transport_url=None, rpc_backend=None,
|
|
||||||
control_exchange=None, allowed=None,
|
|
||||||
aliases=dict(testfoo='testtransport'),
|
|
||||||
expect=dict(backend='testtransport',
|
|
||||||
exchange=None,
|
|
||||||
url='testtransport:',
|
|
||||||
allowed=[]))),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
@mock.patch('oslo_messaging.transport.LOG')
|
@mock.patch('oslo_messaging.transport.LOG')
|
||||||
@ -133,18 +109,8 @@ class GetTransportTestCase(test_utils.BaseTestCase):
|
|||||||
kwargs = dict(url=self.url)
|
kwargs = dict(url=self.url)
|
||||||
if self.allowed is not None:
|
if self.allowed is not None:
|
||||||
kwargs['allowed_remote_exmods'] = self.allowed
|
kwargs['allowed_remote_exmods'] = self.allowed
|
||||||
if self.aliases is not None:
|
|
||||||
kwargs['aliases'] = self.aliases
|
|
||||||
transport_ = oslo_messaging.get_transport(self.conf, **kwargs)
|
transport_ = oslo_messaging.get_transport(self.conf, **kwargs)
|
||||||
|
|
||||||
if self.aliases is not None:
|
|
||||||
self.assertEqual(
|
|
||||||
[mock.call('legacy "rpc_backend" is deprecated, '
|
|
||||||
'"testfoo" must be replaced by '
|
|
||||||
'"%s"' % self.aliases.get('testfoo'))],
|
|
||||||
fake_logger.warning.mock_calls
|
|
||||||
)
|
|
||||||
|
|
||||||
self.assertIsNotNone(transport_)
|
self.assertIsNotNone(transport_)
|
||||||
self.assertIs(transport_.conf, self.conf)
|
self.assertIs(transport_.conf, self.conf)
|
||||||
self.assertIs(transport_._driver, drvr)
|
self.assertIs(transport_._driver, drvr)
|
||||||
|
@ -25,54 +25,51 @@ class TestParseURL(test_utils.BaseTestCase):
|
|||||||
|
|
||||||
scenarios = [
|
scenarios = [
|
||||||
('transport',
|
('transport',
|
||||||
dict(url='foo:', aliases=None,
|
dict(url='foo:',
|
||||||
expect=dict(transport='foo'))),
|
|
||||||
('transport_aliased',
|
|
||||||
dict(url='bar:', aliases=dict(bar='foo'),
|
|
||||||
expect=dict(transport='foo'))),
|
expect=dict(transport='foo'))),
|
||||||
('virtual_host_slash',
|
('virtual_host_slash',
|
||||||
dict(url='foo:////', aliases=None,
|
dict(url='foo:////',
|
||||||
expect=dict(transport='foo', virtual_host='/'))),
|
expect=dict(transport='foo', virtual_host='/'))),
|
||||||
('virtual_host',
|
('virtual_host',
|
||||||
dict(url='foo:///bar', aliases=None,
|
dict(url='foo:///bar',
|
||||||
expect=dict(transport='foo', virtual_host='bar'))),
|
expect=dict(transport='foo', virtual_host='bar'))),
|
||||||
('host',
|
('host',
|
||||||
dict(url='foo://host/bar', aliases=None,
|
dict(url='foo://host/bar',
|
||||||
expect=dict(transport='foo',
|
expect=dict(transport='foo',
|
||||||
virtual_host='bar',
|
virtual_host='bar',
|
||||||
hosts=[
|
hosts=[
|
||||||
dict(host='host'),
|
dict(host='host'),
|
||||||
]))),
|
]))),
|
||||||
('ipv6_host',
|
('ipv6_host',
|
||||||
dict(url='foo://[ffff::1]/bar', aliases=None,
|
dict(url='foo://[ffff::1]/bar',
|
||||||
expect=dict(transport='foo',
|
expect=dict(transport='foo',
|
||||||
virtual_host='bar',
|
virtual_host='bar',
|
||||||
hosts=[
|
hosts=[
|
||||||
dict(host='ffff::1'),
|
dict(host='ffff::1'),
|
||||||
]))),
|
]))),
|
||||||
('port',
|
('port',
|
||||||
dict(url='foo://host:1234/bar', aliases=None,
|
dict(url='foo://host:1234/bar',
|
||||||
expect=dict(transport='foo',
|
expect=dict(transport='foo',
|
||||||
virtual_host='bar',
|
virtual_host='bar',
|
||||||
hosts=[
|
hosts=[
|
||||||
dict(host='host', port=1234),
|
dict(host='host', port=1234),
|
||||||
]))),
|
]))),
|
||||||
('ipv6_port',
|
('ipv6_port',
|
||||||
dict(url='foo://[ffff::1]:1234/bar', aliases=None,
|
dict(url='foo://[ffff::1]:1234/bar',
|
||||||
expect=dict(transport='foo',
|
expect=dict(transport='foo',
|
||||||
virtual_host='bar',
|
virtual_host='bar',
|
||||||
hosts=[
|
hosts=[
|
||||||
dict(host='ffff::1', port=1234),
|
dict(host='ffff::1', port=1234),
|
||||||
]))),
|
]))),
|
||||||
('username',
|
('username',
|
||||||
dict(url='foo://u@host:1234/bar', aliases=None,
|
dict(url='foo://u@host:1234/bar',
|
||||||
expect=dict(transport='foo',
|
expect=dict(transport='foo',
|
||||||
virtual_host='bar',
|
virtual_host='bar',
|
||||||
hosts=[
|
hosts=[
|
||||||
dict(host='host', port=1234, username='u'),
|
dict(host='host', port=1234, username='u'),
|
||||||
]))),
|
]))),
|
||||||
('password',
|
('password',
|
||||||
dict(url='foo://u:p@host:1234/bar', aliases=None,
|
dict(url='foo://u:p@host:1234/bar',
|
||||||
expect=dict(transport='foo',
|
expect=dict(transport='foo',
|
||||||
virtual_host='bar',
|
virtual_host='bar',
|
||||||
hosts=[
|
hosts=[
|
||||||
@ -80,14 +77,14 @@ class TestParseURL(test_utils.BaseTestCase):
|
|||||||
username='u', password='p'),
|
username='u', password='p'),
|
||||||
]))),
|
]))),
|
||||||
('creds_no_host',
|
('creds_no_host',
|
||||||
dict(url='foo://u:p@/bar', aliases=None,
|
dict(url='foo://u:p@/bar',
|
||||||
expect=dict(transport='foo',
|
expect=dict(transport='foo',
|
||||||
virtual_host='bar',
|
virtual_host='bar',
|
||||||
hosts=[
|
hosts=[
|
||||||
dict(username='u', password='p'),
|
dict(username='u', password='p'),
|
||||||
]))),
|
]))),
|
||||||
('multi_host',
|
('multi_host',
|
||||||
dict(url='foo://u:p@host1:1234,host2:4321/bar', aliases=None,
|
dict(url='foo://u:p@host1:1234,host2:4321/bar',
|
||||||
expect=dict(transport='foo',
|
expect=dict(transport='foo',
|
||||||
virtual_host='bar',
|
virtual_host='bar',
|
||||||
hosts=[
|
hosts=[
|
||||||
@ -96,7 +93,7 @@ class TestParseURL(test_utils.BaseTestCase):
|
|||||||
dict(host='host2', port=4321),
|
dict(host='host2', port=4321),
|
||||||
]))),
|
]))),
|
||||||
('multi_host_partial_creds',
|
('multi_host_partial_creds',
|
||||||
dict(url='foo://u:p@host1,host2/bar', aliases=None,
|
dict(url='foo://u:p@host1,host2/bar',
|
||||||
expect=dict(transport='foo',
|
expect=dict(transport='foo',
|
||||||
virtual_host='bar',
|
virtual_host='bar',
|
||||||
hosts=[
|
hosts=[
|
||||||
@ -104,7 +101,7 @@ class TestParseURL(test_utils.BaseTestCase):
|
|||||||
dict(host='host2'),
|
dict(host='host2'),
|
||||||
]))),
|
]))),
|
||||||
('multi_creds',
|
('multi_creds',
|
||||||
dict(url='foo://u1:p1@host1:1234,u2:p2@host2:4321/bar', aliases=None,
|
dict(url='foo://u1:p1@host1:1234,u2:p2@host2:4321/bar',
|
||||||
expect=dict(transport='foo',
|
expect=dict(transport='foo',
|
||||||
virtual_host='bar',
|
virtual_host='bar',
|
||||||
hosts=[
|
hosts=[
|
||||||
@ -115,7 +112,6 @@ class TestParseURL(test_utils.BaseTestCase):
|
|||||||
]))),
|
]))),
|
||||||
('multi_creds_ipv6',
|
('multi_creds_ipv6',
|
||||||
dict(url='foo://u1:p1@[ffff::1]:1234,u2:p2@[ffff::2]:4321/bar',
|
dict(url='foo://u1:p1@[ffff::1]:1234,u2:p2@[ffff::2]:4321/bar',
|
||||||
aliases=None,
|
|
||||||
expect=dict(transport='foo',
|
expect=dict(transport='foo',
|
||||||
virtual_host='bar',
|
virtual_host='bar',
|
||||||
hosts=[
|
hosts=[
|
||||||
@ -125,7 +121,7 @@ class TestParseURL(test_utils.BaseTestCase):
|
|||||||
username='u2', password='p2'),
|
username='u2', password='p2'),
|
||||||
]))),
|
]))),
|
||||||
('quoting',
|
('quoting',
|
||||||
dict(url='foo://u%24:p%26@host:1234/%24', aliases=None,
|
dict(url='foo://u%24:p%26@host:1234/%24',
|
||||||
expect=dict(transport='foo',
|
expect=dict(transport='foo',
|
||||||
virtual_host='$',
|
virtual_host='$',
|
||||||
hosts=[
|
hosts=[
|
||||||
@ -137,8 +133,7 @@ class TestParseURL(test_utils.BaseTestCase):
|
|||||||
def test_parse_url(self):
|
def test_parse_url(self):
|
||||||
self.config(rpc_backend=None)
|
self.config(rpc_backend=None)
|
||||||
|
|
||||||
url = oslo_messaging.TransportURL.parse(self.conf, self.url,
|
url = oslo_messaging.TransportURL.parse(self.conf, self.url)
|
||||||
self.aliases)
|
|
||||||
|
|
||||||
hosts = []
|
hosts = []
|
||||||
for host in self.expect.get('hosts', []):
|
for host in self.expect.get('hosts', []):
|
||||||
@ -162,35 +157,18 @@ class TestFormatURL(test_utils.BaseTestCase):
|
|||||||
transport=None,
|
transport=None,
|
||||||
virtual_host=None,
|
virtual_host=None,
|
||||||
hosts=[],
|
hosts=[],
|
||||||
aliases=None,
|
|
||||||
expected='testbackend:///')),
|
|
||||||
('rpc_backend_aliased',
|
|
||||||
dict(rpc_backend='testfoo',
|
|
||||||
transport=None,
|
|
||||||
virtual_host=None,
|
|
||||||
hosts=[],
|
|
||||||
aliases=dict(testfoo='testbackend'),
|
|
||||||
expected='testbackend:///')),
|
expected='testbackend:///')),
|
||||||
('transport',
|
('transport',
|
||||||
dict(rpc_backend=None,
|
dict(rpc_backend=None,
|
||||||
transport='testtransport',
|
transport='testtransport',
|
||||||
virtual_host=None,
|
virtual_host=None,
|
||||||
hosts=[],
|
hosts=[],
|
||||||
aliases=None,
|
|
||||||
expected='testtransport:///')),
|
|
||||||
('transport_aliased',
|
|
||||||
dict(rpc_backend=None,
|
|
||||||
transport='testfoo',
|
|
||||||
virtual_host=None,
|
|
||||||
hosts=[],
|
|
||||||
aliases=dict(testfoo='testtransport'),
|
|
||||||
expected='testtransport:///')),
|
expected='testtransport:///')),
|
||||||
('virtual_host',
|
('virtual_host',
|
||||||
dict(rpc_backend=None,
|
dict(rpc_backend=None,
|
||||||
transport='testtransport',
|
transport='testtransport',
|
||||||
virtual_host='/vhost',
|
virtual_host='/vhost',
|
||||||
hosts=[],
|
hosts=[],
|
||||||
aliases=None,
|
|
||||||
expected='testtransport:////vhost')),
|
expected='testtransport:////vhost')),
|
||||||
('host',
|
('host',
|
||||||
dict(rpc_backend=None,
|
dict(rpc_backend=None,
|
||||||
@ -202,7 +180,6 @@ class TestFormatURL(test_utils.BaseTestCase):
|
|||||||
username='bob',
|
username='bob',
|
||||||
password='secret'),
|
password='secret'),
|
||||||
],
|
],
|
||||||
aliases=None,
|
|
||||||
expected='testtransport://bob:secret@host:10//')),
|
expected='testtransport://bob:secret@host:10//')),
|
||||||
('multi_host',
|
('multi_host',
|
||||||
dict(rpc_backend=None,
|
dict(rpc_backend=None,
|
||||||
@ -218,7 +195,6 @@ class TestFormatURL(test_utils.BaseTestCase):
|
|||||||
username='b2',
|
username='b2',
|
||||||
password='s2'),
|
password='s2'),
|
||||||
],
|
],
|
||||||
aliases=None,
|
|
||||||
expected='testtransport://b1:s1@h1:1000,b2:s2@h2:2000/')),
|
expected='testtransport://b1:s1@h1:1000,b2:s2@h2:2000/')),
|
||||||
('quoting',
|
('quoting',
|
||||||
dict(rpc_backend=None,
|
dict(rpc_backend=None,
|
||||||
@ -230,7 +206,6 @@ class TestFormatURL(test_utils.BaseTestCase):
|
|||||||
username='b$',
|
username='b$',
|
||||||
password='s&'),
|
password='s&'),
|
||||||
],
|
],
|
||||||
aliases=None,
|
|
||||||
expected='testtransport://b%24:s%26@host:10//%24')),
|
expected='testtransport://b%24:s%26@host:10//%24')),
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -244,10 +219,7 @@ class TestFormatURL(test_utils.BaseTestCase):
|
|||||||
host.get('username'),
|
host.get('username'),
|
||||||
host.get('password')))
|
host.get('password')))
|
||||||
|
|
||||||
url = oslo_messaging.TransportURL(self.conf,
|
url = oslo_messaging.TransportURL(self.conf, self.transport,
|
||||||
self.transport,
|
self.virtual_host, hosts)
|
||||||
self.virtual_host,
|
|
||||||
hosts,
|
|
||||||
self.aliases)
|
|
||||||
|
|
||||||
self.assertEqual(self.expected, str(url))
|
self.assertEqual(self.expected, str(url))
|
||||||
|
@ -195,13 +195,13 @@ class DriverLoadFailure(exceptions.MessagingException):
|
|||||||
self.ex = ex
|
self.ex = ex
|
||||||
|
|
||||||
|
|
||||||
def _get_transport(conf, url=None, allowed_remote_exmods=None, aliases=None,
|
def _get_transport(conf, url=None, allowed_remote_exmods=None,
|
||||||
transport_cls=RPCTransport):
|
transport_cls=RPCTransport):
|
||||||
allowed_remote_exmods = allowed_remote_exmods or []
|
allowed_remote_exmods = allowed_remote_exmods or []
|
||||||
conf.register_opts(_transport_opts)
|
conf.register_opts(_transport_opts)
|
||||||
|
|
||||||
if not isinstance(url, TransportURL):
|
if not isinstance(url, TransportURL):
|
||||||
url = TransportURL.parse(conf, url, aliases)
|
url = TransportURL.parse(conf, url)
|
||||||
|
|
||||||
kwargs = dict(default_exchange=conf.control_exchange,
|
kwargs = dict(default_exchange=conf.control_exchange,
|
||||||
allowed_remote_exmods=allowed_remote_exmods)
|
allowed_remote_exmods=allowed_remote_exmods)
|
||||||
@ -221,9 +221,7 @@ def _get_transport(conf, url=None, allowed_remote_exmods=None, aliases=None,
|
|||||||
@removals.remove(
|
@removals.remove(
|
||||||
message='use get_rpc_transport or get_notification_transport'
|
message='use get_rpc_transport or get_notification_transport'
|
||||||
)
|
)
|
||||||
@removals.removed_kwarg('aliases',
|
def get_transport(conf, url=None, allowed_remote_exmods=None):
|
||||||
'Parameter aliases is deprecated for removal.')
|
|
||||||
def get_transport(conf, url=None, allowed_remote_exmods=None, aliases=None):
|
|
||||||
"""A factory method for Transport objects.
|
"""A factory method for Transport objects.
|
||||||
|
|
||||||
This method will construct a Transport object from transport configuration
|
This method will construct a Transport object from transport configuration
|
||||||
@ -250,11 +248,8 @@ def get_transport(conf, url=None, allowed_remote_exmods=None, aliases=None):
|
|||||||
transport will deserialize remote exceptions
|
transport will deserialize remote exceptions
|
||||||
from
|
from
|
||||||
:type allowed_remote_exmods: list
|
:type allowed_remote_exmods: list
|
||||||
:param aliases: DEPRECATED: A map of transport alias to transport name
|
|
||||||
:type aliases: dict
|
|
||||||
"""
|
"""
|
||||||
return _get_transport(conf, url,
|
return _get_transport(conf, url, allowed_remote_exmods,
|
||||||
allowed_remote_exmods, aliases,
|
|
||||||
transport_cls=RPCTransport)
|
transport_cls=RPCTransport)
|
||||||
|
|
||||||
|
|
||||||
@ -336,16 +331,12 @@ class TransportURL(object):
|
|||||||
:type virtual_host: str
|
:type virtual_host: str
|
||||||
:param hosts: a list of TransportHost objects
|
:param hosts: a list of TransportHost objects
|
||||||
:type hosts: list
|
:type hosts: list
|
||||||
:param aliases: DEPRECATED: a map of transport alias to transport name
|
|
||||||
:type aliases: dict
|
|
||||||
:param query: a dictionary of URL query parameters
|
:param query: a dictionary of URL query parameters
|
||||||
:type query: dict
|
:type query: dict
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@removals.removed_kwarg('aliases',
|
|
||||||
'Parameter aliases is deprecated for removal.')
|
|
||||||
def __init__(self, conf, transport=None, virtual_host=None, hosts=None,
|
def __init__(self, conf, transport=None, virtual_host=None, hosts=None,
|
||||||
aliases=None, query=None):
|
query=None):
|
||||||
self.conf = conf
|
self.conf = conf
|
||||||
self.conf.register_opts(_transport_opts)
|
self.conf.register_opts(_transport_opts)
|
||||||
self._transport = transport
|
self._transport = transport
|
||||||
@ -354,10 +345,6 @@ class TransportURL(object):
|
|||||||
self.hosts = []
|
self.hosts = []
|
||||||
else:
|
else:
|
||||||
self.hosts = hosts
|
self.hosts = hosts
|
||||||
if aliases is None:
|
|
||||||
self.aliases = {}
|
|
||||||
else:
|
|
||||||
self.aliases = aliases
|
|
||||||
if query is None:
|
if query is None:
|
||||||
self.query = {}
|
self.query = {}
|
||||||
else:
|
else:
|
||||||
@ -371,7 +358,7 @@ class TransportURL(object):
|
|||||||
transport = self.conf.rpc_backend
|
transport = self.conf.rpc_backend
|
||||||
else:
|
else:
|
||||||
transport = self._transport
|
transport = self._transport
|
||||||
final_transport = self.aliases.get(transport, transport)
|
final_transport = transport
|
||||||
if not self._deprecation_logged and final_transport != transport:
|
if not self._deprecation_logged and final_transport != transport:
|
||||||
# NOTE(sileht): The first step is deprecate this one cycle.
|
# NOTE(sileht): The first step is deprecate this one cycle.
|
||||||
# To ensure deployer have updated they configuration during Ocata
|
# To ensure deployer have updated they configuration during Ocata
|
||||||
@ -452,10 +439,8 @@ class TransportURL(object):
|
|||||||
|
|
||||||
return url
|
return url
|
||||||
|
|
||||||
@removals.removed_kwarg('aliases',
|
|
||||||
'Parameter aliases is deprecated for removal.')
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse(cls, conf, url=None, aliases=None):
|
def parse(cls, conf, url=None):
|
||||||
"""Parse a URL as defined by :py:class:`TransportURL` and return a
|
"""Parse a URL as defined by :py:class:`TransportURL` and return a
|
||||||
TransportURL object.
|
TransportURL object.
|
||||||
|
|
||||||
@ -485,8 +470,6 @@ class TransportURL(object):
|
|||||||
:type conf: oslo.config.cfg.ConfigOpts
|
:type conf: oslo.config.cfg.ConfigOpts
|
||||||
:param url: The URL to parse
|
:param url: The URL to parse
|
||||||
:type url: str
|
:type url: str
|
||||||
:param aliases: A map of transport alias to transport name
|
|
||||||
:type aliases: dict
|
|
||||||
:returns: A TransportURL
|
:returns: A TransportURL
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -494,7 +477,7 @@ class TransportURL(object):
|
|||||||
conf.register_opts(_transport_opts)
|
conf.register_opts(_transport_opts)
|
||||||
url = url or conf.transport_url
|
url = url or conf.transport_url
|
||||||
if not url:
|
if not url:
|
||||||
return cls(conf) if aliases is None else cls(conf, aliases=aliases)
|
return cls(conf)
|
||||||
|
|
||||||
if not isinstance(url, six.string_types):
|
if not isinstance(url, six.string_types):
|
||||||
raise InvalidTransportURL(url, 'Wrong URL type')
|
raise InvalidTransportURL(url, 'Wrong URL type')
|
||||||
@ -578,7 +561,4 @@ class TransportURL(object):
|
|||||||
{'hosts_with_credentials': hosts_with_credentials,
|
{'hosts_with_credentials': hosts_with_credentials,
|
||||||
'hosts_without_credentials':
|
'hosts_without_credentials':
|
||||||
hosts_without_credentials})
|
hosts_without_credentials})
|
||||||
if aliases is None:
|
return cls(conf, transport, virtual_host, hosts, query)
|
||||||
return cls(conf, transport, virtual_host, hosts, query=query)
|
|
||||||
else:
|
|
||||||
return cls(conf, transport, virtual_host, hosts, aliases, query)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user