diff --git a/mistral/context.py b/mistral/context.py index 88fc63d2..5cc1be84 100644 --- a/mistral/context.py +++ b/mistral/context.py @@ -19,6 +19,7 @@ from keystoneclient.v3 import client as keystone_client import logging from oslo_config import cfg import oslo_messaging as messaging +from oslo_messaging import serializer as messaging_serializer from oslo_serialization import jsonutils from osprofiler import profiler import pecan @@ -225,15 +226,9 @@ def context_from_config(): ) -class JsonPayloadSerializer(messaging.NoOpSerializer): - @staticmethod - def serialize_entity(context, entity): - return jsonutils.to_primitive(entity, convert_instances=True) - - class RpcContextSerializer(messaging.Serializer): def __init__(self, base=None): - self._base = base or messaging.NoOpSerializer() + self._base = base or messaging_serializer.JsonPayloadSerializer() def serialize_entity(self, context, entity): if not self._base: diff --git a/mistral/engine/rpc_backend/oslo/oslo_client.py b/mistral/engine/rpc_backend/oslo/oslo_client.py index 7a8df391..2fde5698 100644 --- a/mistral/engine/rpc_backend/oslo/oslo_client.py +++ b/mistral/engine/rpc_backend/oslo/oslo_client.py @@ -24,8 +24,7 @@ class OsloRPCClient(rpc_base.RPCClient): super(OsloRPCClient, self).__init__(conf) self.topic = conf.topic - serializer = auth_ctx.RpcContextSerializer( - auth_ctx.JsonPayloadSerializer()) + serializer = auth_ctx.RpcContextSerializer() self._client = messaging.RPCClient( rpc.get_transport(), diff --git a/mistral/engine/rpc_backend/oslo/oslo_server.py b/mistral/engine/rpc_backend/oslo/oslo_server.py index 3d255eba..0f509eff 100644 --- a/mistral/engine/rpc_backend/oslo/oslo_server.py +++ b/mistral/engine/rpc_backend/oslo/oslo_server.py @@ -52,7 +52,7 @@ class OsloRPCServer(rpc_base.RPCServer): target, self.endpoints, executor=executor, - serializer=ctx.RpcContextSerializer(ctx.JsonPayloadSerializer()) + serializer=ctx.RpcContextSerializer() ) self.oslo_server.start() diff --git a/mistral/services/scheduler.py b/mistral/services/scheduler.py index 1041a557..17609a23 100644 --- a/mistral/services/scheduler.py +++ b/mistral/services/scheduler.py @@ -58,9 +58,7 @@ def schedule_call(factory_method_path, target_method_name, delayed calls. :param method_args: Target method keyword arguments. """ - ctx_serializer = context.RpcContextSerializer( - context.JsonPayloadSerializer() - ) + ctx_serializer = context.RpcContextSerializer() ctx = ( ctx_serializer.serialize_context(context.ctx()) @@ -167,9 +165,7 @@ class CallScheduler(periodic_task.PeriodicTasks): (target_auth_context, target_method, method_args) ) - ctx_serializer = context.RpcContextSerializer( - context.JsonPayloadSerializer() - ) + ctx_serializer = context.RpcContextSerializer() for (target_auth_context, target_method, method_args) in delayed_calls: try: diff --git a/mistral/tests/unit/engine/test_profiler.py b/mistral/tests/unit/engine/test_profiler.py index ec58bf88..67ebb92b 100644 --- a/mistral/tests/unit/engine/test_profiler.py +++ b/mistral/tests/unit/engine/test_profiler.py @@ -40,9 +40,7 @@ class EngineProfilerTest(base.EngineTestCase): self.mock_profiler_log_func = mock.Mock(return_value=None) osprofiler.notifier.set(self.mock_profiler_log_func) - self.ctx_serializer = context.RpcContextSerializer( - context.JsonPayloadSerializer() - ) + self.ctx_serializer = context.RpcContextSerializer() def test_profile_trace(self): wf_def = """