Replace get_transport with get_rpc_transport

With the added get_rpc_transport() function in oslo.messaging [1]
and the recent version bump of oslo.messaging to 5.24.2, we can
safely replace get_transport() with get_rpc_transport() which is much
cleaner.

[1] https://review.openstack.org/#/c/454194/

Change-Id: Icc3cf50609cae230ca3fe540dc062201de3ea9df
This commit is contained in:
akhiljain23 2017-06-07 12:37:00 +05:30
parent ae47dbee44
commit c90bb86e20
2 changed files with 10 additions and 10 deletions

View File

@ -38,8 +38,8 @@ def init(conf):
global TRANSPORT, NOTIFICATION_TRANSPORT
global SENSORS_NOTIFIER, VERSIONED_NOTIFIER
exmods = get_allowed_exmods()
TRANSPORT = messaging.get_transport(conf,
allowed_remote_exmods=exmods)
TRANSPORT = messaging.get_rpc_transport(conf,
allowed_remote_exmods=exmods)
NOTIFICATION_TRANSPORT = messaging.get_notification_transport(
conf,
allowed_remote_exmods=exmods)

View File

@ -26,29 +26,29 @@ class TestUtils(base.TestCase):
@mock.patch.object(messaging, 'Notifier', autospec=True)
@mock.patch.object(messaging, 'JsonPayloadSerializer', autospec=True)
@mock.patch.object(messaging, 'get_notification_transport', autospec=True)
@mock.patch.object(messaging, 'get_transport', autospec=True)
def test_init_globals_notifications_disabled(self, mock_get_transport,
@mock.patch.object(messaging, 'get_rpc_transport', autospec=True)
def test_init_globals_notifications_disabled(self, mock_get_rpc_transport,
mock_get_notification,
mock_json_serializer,
mock_notifier):
self._test_init_globals(False, mock_get_transport,
self._test_init_globals(False, mock_get_rpc_transport,
mock_get_notification, mock_json_serializer,
mock_notifier)
@mock.patch.object(messaging, 'Notifier', autospec=True)
@mock.patch.object(messaging, 'JsonPayloadSerializer', autospec=True)
@mock.patch.object(messaging, 'get_notification_transport', autospec=True)
@mock.patch.object(messaging, 'get_transport', autospec=True)
def test_init_globals_notifications_enabled(self, mock_get_transport,
@mock.patch.object(messaging, 'get_rpc_transport', autospec=True)
def test_init_globals_notifications_enabled(self, mock_get_rpc_transport,
mock_get_notification,
mock_json_serializer,
mock_notifier):
self.config(notification_level='debug')
self._test_init_globals(True, mock_get_transport,
self._test_init_globals(True, mock_get_rpc_transport,
mock_get_notification, mock_json_serializer,
mock_notifier)
def _test_init_globals(self, notifications_enabled, mock_get_transport,
def _test_init_globals(self, notifications_enabled, mock_get_rpc_transport,
mock_get_notification, mock_json_serializer,
mock_notifier):
rpc.TRANSPORT = None
@ -66,7 +66,7 @@ class TestUtils(base.TestCase):
rpc.init(CONF)
self.assertEqual(mock_get_transport.return_value, rpc.TRANSPORT)
self.assertEqual(mock_get_rpc_transport.return_value, rpc.TRANSPORT)
self.assertEqual(mock_get_notification.return_value,
rpc.NOTIFICATION_TRANSPORT)
self.assertTrue(mock_json_serializer.called)