Use new get_rpc_client API from oslo.messaging

Use the new API that is consistent with
the existing API instead of instantiating the client
class directly.

This was introduced in release 14.1.0 here [1] and
added into oslo.messaging here [2]

[1] https://review.opendev.org/c/openstack/requirements/+/869340
[2] https://review.opendev.org/c/openstack/oslo.messaging/+/862419

Change-Id: I33d55df17fcf9ca69b4a3dc1906b440b9cb87b46
This commit is contained in:
Tobias Urdin 2023-01-19 20:35:43 +00:00 committed by Gregory Thiemonge
parent 0f9050ff61
commit 244f44ae6c
4 changed files with 8 additions and 10 deletions

View File

@ -176,11 +176,10 @@ class AmphoraUpdateController(base.BaseController):
else:
topic = constants.TOPIC_AMPHORA_V2
version = "2.0"
self.transport = messaging.get_rpc_transport(cfg.CONF)
self.target = messaging.Target(
namespace=constants.RPC_NAMESPACE_CONTROLLER_AGENT,
topic=topic, version=version, fanout=False)
self.client = messaging.RPCClient(self.transport, target=self.target)
self.client = rpc.get_client(self.target)
self.amp_id = amp_id
@wsme_pecan.wsexpose(None, wtypes.text, status_code=202)

View File

@ -47,11 +47,10 @@ def get_client(target, version_cap=None, serializer=None,
assert TRANSPORT is not None, _("'TRANSPORT' must not be None")
return messaging.RPCClient(TRANSPORT,
target,
version_cap=version_cap,
serializer=serializer,
call_monitor_timeout=call_monitor_timeout)
return messaging.get_rpc_client(
TRANSPORT, target, version_cap=version_cap,
serializer=serializer,
call_monitor_timeout=call_monitor_timeout)
def get_server(target, endpoints, executor='threading',

View File

@ -1040,7 +1040,7 @@ class TestLoadBalancer(base.BaseAPITest):
".get_network") as mock_get_network, mock.patch(
'oslo_messaging.get_rpc_transport'), mock.patch(
'oslo_messaging.Target'), mock.patch(
'oslo_messaging.RPCClient'):
'oslo_messaging.get_rpc_client'):
mock_get_network.return_value = mock.MagicMock()
mock_get_network.return_value.port_security_enabled = True
response = self.post(self.LBS_PATH, body)
@ -1061,7 +1061,7 @@ class TestLoadBalancer(base.BaseAPITest):
".get_network") as mock_get_network, mock.patch(
'oslo_messaging.get_rpc_transport'), mock.patch(
'oslo_messaging.Target'), mock.patch(
'oslo_messaging.RPCClient'):
'oslo_messaging.get_rpc_client'):
mock_get_network.return_value = mock.MagicMock()
mock_get_network.return_value.port_security_enabled = False
response = self.post(self.LBS_PATH, body, status=500)

View File

@ -24,7 +24,7 @@ oslo.context>=2.22.0 # Apache-2.0
oslo.db[mysql]>=8.4.0 # Apache-2.0
oslo.i18n>=3.20.0 # Apache-2.0
oslo.log>=4.3.0 # Apache-2.0
oslo.messaging>=12.4.0 # Apache-2.0
oslo.messaging>=14.1.0 # Apache-2.0
oslo.middleware>=4.0.1 # Apache-2.0
oslo.policy>=3.7.0 # Apache-2.0
oslo.reports>=1.18.0 # Apache-2.0