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: I31e572d760600f890402a53f0d34eb1b87d722d7
This commit is contained in:

committed by
Deepak Mourya

parent
d748264866
commit
21a4fb6f92
@@ -29,6 +29,7 @@ __all__ = [
|
|||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import oslo_messaging as messaging
|
import oslo_messaging as messaging
|
||||||
|
from oslo_messaging.rpc import dispatcher
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
|
|
||||||
from cloudpulse.common import context as cloudpulse_context
|
from cloudpulse.common import context as cloudpulse_context
|
||||||
@@ -132,12 +133,14 @@ def get_client(target, version_cap=None, serializer=None):
|
|||||||
|
|
||||||
def get_server(target, endpoints, serializer=None):
|
def get_server(target, endpoints, serializer=None):
|
||||||
assert TRANSPORT is not None
|
assert TRANSPORT is not None
|
||||||
|
access_policy = dispatcher.DefaultRPCAccessPolicy
|
||||||
serializer = RequestContextSerializer(serializer)
|
serializer = RequestContextSerializer(serializer)
|
||||||
return messaging.get_rpc_server(TRANSPORT,
|
return messaging.get_rpc_server(TRANSPORT,
|
||||||
target,
|
target,
|
||||||
endpoints,
|
endpoints,
|
||||||
executor='eventlet',
|
executor='eventlet',
|
||||||
serializer=serializer)
|
serializer=serializer,
|
||||||
|
access_policy=access_policy)
|
||||||
|
|
||||||
|
|
||||||
def get_notifier(service=None, host=None, publisher_id=None):
|
def get_notifier(service=None, host=None, publisher_id=None):
|
||||||
|
@@ -17,12 +17,12 @@
|
|||||||
import eventlet
|
import eventlet
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import oslo_messaging as messaging
|
import oslo_messaging as messaging
|
||||||
|
from oslo_messaging.rpc import dispatcher
|
||||||
|
|
||||||
from cloudpulse.common import context as cloudpulse_context
|
from cloudpulse.common import context as cloudpulse_context
|
||||||
from cloudpulse.common import rpc
|
from cloudpulse.common import rpc
|
||||||
from cloudpulse.objects import base as objects_base
|
from cloudpulse.objects import base as objects_base
|
||||||
|
|
||||||
|
|
||||||
# NOTE(paulczar):
|
# NOTE(paulczar):
|
||||||
# Ubuntu 14.04 forces librabbitmq when kombu is used
|
# Ubuntu 14.04 forces librabbitmq when kombu is used
|
||||||
# Unfortunately it forces a version that has a crash
|
# Unfortunately it forces a version that has a crash
|
||||||
@@ -72,8 +72,10 @@ class Service(object):
|
|||||||
aliases=TRANSPORT_ALIASES)
|
aliases=TRANSPORT_ALIASES)
|
||||||
# TODO(asalkeld) add support for version='x.y'
|
# TODO(asalkeld) add support for version='x.y'
|
||||||
target = messaging.Target(topic=topic, server=server)
|
target = messaging.Target(topic=topic, server=server)
|
||||||
|
access_policy = dispatcher.DefaultRPCAccessPolicy
|
||||||
self._server = messaging.get_rpc_server(transport, target, handlers,
|
self._server = messaging.get_rpc_server(transport, target, handlers,
|
||||||
serializer=serializer)
|
serializer=serializer,
|
||||||
|
access_policy=access_policy)
|
||||||
|
|
||||||
def serve(self):
|
def serve(self):
|
||||||
self._server.start()
|
self._server.start()
|
||||||
|
Reference in New Issue
Block a user