Set access_policy for messaging's dispatcher
oslo.messaging allow dispatcher to restrict endpoint methods since 5.11.0 in I42239e6c8a8be158ddf5c3b1773463b7dc93e881, set with LegacyRPCAccessPolicy explicitly to ensure it's compatible and fix FutureWarning like: "The access_policy argument is changing its default value to <class 'oslo_messaging.rpc.dispatcher.DefaultRPCAccessPolicy'> in version '?', please update the code to explicitly set None as the value: access_policy defaults to LegacyRPCAccessPolicy which exposes private methods. Explicitly set access_policy to DefaultRPCAccessPolicy or ExplicitRPCAccessPolicy. Change-Id: Ia8922baf422ee84e55f05534678b2f0377843688
This commit is contained in:
parent
c8b5095bce
commit
c7dd0ab6b8
@ -22,6 +22,7 @@ from neutron_lib import exceptions as lib_exceptions
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
from oslo_messaging.rpc import dispatcher
|
||||
from oslo_messaging import serializer as om_serializer
|
||||
from oslo_service import service
|
||||
from oslo_utils import excutils
|
||||
@ -171,8 +172,10 @@ def get_client(target, version_cap=None, serializer=None):
|
||||
def get_server(target, endpoints, serializer=None):
|
||||
assert TRANSPORT is not None
|
||||
serializer = RequestContextSerializer(serializer)
|
||||
access_policy = dispatcher.LegacyRPCAccessPolicy
|
||||
return oslo_messaging.get_rpc_server(TRANSPORT, target, endpoints,
|
||||
'eventlet', serializer)
|
||||
'eventlet', serializer,
|
||||
access_policy=access_policy)
|
||||
|
||||
|
||||
def get_notifier(service=None, host=None, publisher_id=None):
|
||||
|
@ -20,6 +20,7 @@ import mock
|
||||
from oslo_config import cfg
|
||||
import oslo_messaging as messaging
|
||||
from oslo_messaging import conffixture as messaging_conffixture
|
||||
from oslo_messaging.rpc import dispatcher
|
||||
import testtools
|
||||
|
||||
from neutron.common import rpc
|
||||
@ -167,8 +168,10 @@ class TestRPC(base.DietTestCase):
|
||||
server = rpc.get_server(tgt, ends, serializer='foo')
|
||||
|
||||
mock_ser.assert_called_once_with('foo')
|
||||
access_policy = dispatcher.LegacyRPCAccessPolicy
|
||||
mock_get.assert_called_once_with(rpc.TRANSPORT, tgt, ends,
|
||||
'eventlet', ser)
|
||||
'eventlet', ser,
|
||||
access_policy=access_policy)
|
||||
self.assertEqual('server', server)
|
||||
|
||||
def test_get_notifier(self):
|
||||
|
Loading…
Reference in New Issue
Block a user