Set access_policy for messaging's dispatcher

oslo.messaging allow dispatcher to restrict endpoint methods since
5.11.0 in d3a8f280ebd6fd12865fd20c4d772774e39aefa2, the default
value of access_policy is LegacyRPCAccessPolicy.
set with DefaultRPCAccessPolicy to fix FutureWarning like:

"The access_policy argument is changing its default value to <class
'oslo_messaging.rpc.dispatcher.DefaultRPCAccessPolicy'> in version 'xxx',
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: I7a220e6fc27e30dbbde4326c071a3f0390f6da43
This commit is contained in:
Shu Yingya 2017-01-03 08:10:10 +00:00
parent 909ca0c01c
commit 6d78370a7a
1 changed files with 4 additions and 1 deletions

View File

@ -17,6 +17,7 @@
from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging as messaging
from oslo_messaging.rpc import dispatcher
from oslo_serialization import jsonutils
from sahara import context
@ -84,11 +85,13 @@ class RPCServer(object):
def __init__(self, target):
global MESSAGING_TRANSPORT
access_policy = dispatcher.DefaultRPCAccessPolicy
self.__server = messaging.get_rpc_server(
target=target,
transport=MESSAGING_TRANSPORT,
endpoints=[self],
executor='eventlet')
executor='eventlet',
access_policy=access_policy)
def get_service(self):
return self.__server