deprecate usage of transport aliases
This change starts the deprecation process for the transport aliases. The first step is deprecate this one cycle. To ensure deployer have updated they configuration during Newton Then in Octacia we will deprecate 'aliases' kwargs of transportURL() and get_transport() for consuming application. Related-bug: #1424728 Change-Id: I314cefa5fb1803fa7e21e3e34300e5ced31bba89
This commit is contained in:
parent
7809cdc602
commit
4d0f7ab652
@ -14,6 +14,7 @@
|
||||
# under the License.
|
||||
|
||||
import fixtures
|
||||
import mock
|
||||
from mox3 import mox
|
||||
from oslo_config import cfg
|
||||
import six
|
||||
@ -112,7 +113,8 @@ class GetTransportTestCase(test_utils.BaseTestCase):
|
||||
allowed=[]))),
|
||||
]
|
||||
|
||||
def test_get_transport(self):
|
||||
@mock.patch('oslo_messaging.transport.LOG')
|
||||
def test_get_transport(self, fake_logger):
|
||||
self.config(rpc_backend=self.rpc_backend,
|
||||
control_exchange=self.control_exchange,
|
||||
transport_url=self.transport_url)
|
||||
@ -142,6 +144,12 @@ class GetTransportTestCase(test_utils.BaseTestCase):
|
||||
kwargs['aliases'] = self.aliases
|
||||
transport_ = oslo_messaging.get_transport(self.conf, **kwargs)
|
||||
|
||||
if self.aliases is not None:
|
||||
self.assertEqual(fake_logger.warning.mock_calls,
|
||||
[mock.call('legacy "rpc_backend" is deprecated, '
|
||||
'"testfoo" must be replaced by '
|
||||
'"%s"' % self.aliases.get('testfoo'))])
|
||||
|
||||
self.assertIsNotNone(transport_)
|
||||
self.assertIs(transport_.conf, self.conf)
|
||||
self.assertIs(transport_._driver, drvr)
|
||||
|
@ -27,6 +27,8 @@ __all__ = [
|
||||
'set_transport_defaults',
|
||||
]
|
||||
|
||||
import logging
|
||||
|
||||
from oslo_config import cfg
|
||||
import six
|
||||
from six.moves.urllib import parse
|
||||
@ -34,6 +36,7 @@ from stevedore import driver
|
||||
|
||||
from oslo_messaging import exceptions
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
_transport_opts = [
|
||||
cfg.StrOpt('transport_url',
|
||||
@ -240,7 +243,7 @@ class TransportURL(object):
|
||||
:type virtual_host: str
|
||||
:param hosts: a list of TransportHost objects
|
||||
:type hosts: list
|
||||
:param aliases: A map of transport alias to transport name
|
||||
:param aliases: DEPRECATED: A map of transport alias to transport name
|
||||
:type aliases: dict
|
||||
"""
|
||||
|
||||
@ -259,13 +262,28 @@ class TransportURL(object):
|
||||
else:
|
||||
self.aliases = aliases
|
||||
|
||||
self._deprecation_logged = False
|
||||
|
||||
@property
|
||||
def transport(self):
|
||||
if self._transport is None:
|
||||
transport = self.conf.rpc_backend
|
||||
else:
|
||||
transport = self._transport
|
||||
return self.aliases.get(transport, transport)
|
||||
final_transport = self.aliases.get(transport, transport)
|
||||
if not self._deprecation_logged and final_transport != transport:
|
||||
# NOTE(sileht): The first step is deprecate this one cycle.
|
||||
# To ensure deployer have updated they configuration during Octavia
|
||||
# Then in P we will deprecate aliases kwargs of TransportURL() and
|
||||
# get_transport() for consuming application
|
||||
LOG.warning('legacy "rpc_backend" is deprecated, '
|
||||
'"%(legacy_transport)s" must be replaced by '
|
||||
'"%(final_transport)s"' % {
|
||||
'legacy_transport': transport,
|
||||
'final_transport': final_transport})
|
||||
self._deprecation_logged = True
|
||||
|
||||
return final_transport
|
||||
|
||||
@transport.setter
|
||||
def transport(self, value):
|
||||
|
Loading…
Reference in New Issue
Block a user