Serialize the notification payload
Notification payload in oslomessaging needs to be serialized correctly, currently it's not. Use json to encode the payload. Closes-Bug: 1294949 Change-Id: Idb2c13981cc1c60ed02445a28220d1dab1529d2b
This commit is contained in:
committed by
Flavio Percoco
parent
a4291a82fc
commit
caff15af26
@@ -31,6 +31,7 @@ from oslo import messaging
|
||||
|
||||
import cinder.context
|
||||
import cinder.exception
|
||||
from cinder.openstack.common import jsonutils
|
||||
|
||||
CONF = cfg.CONF
|
||||
TRANSPORT = None
|
||||
@@ -60,8 +61,9 @@ def init(conf):
|
||||
TRANSPORT = messaging.get_transport(conf,
|
||||
allowed_remote_exmods=exmods,
|
||||
aliases=TRANSPORT_ALIASES)
|
||||
NOTIFIER = messaging.Notifier(TRANSPORT,
|
||||
serializer=RequestContextSerializer(None))
|
||||
|
||||
serializer = RequestContextSerializer(JsonPayloadSerializer())
|
||||
NOTIFIER = messaging.Notifier(TRANSPORT, serializer=serializer)
|
||||
|
||||
|
||||
def initialized():
|
||||
@@ -92,6 +94,12 @@ def get_allowed_exmods():
|
||||
return ALLOWED_EXMODS + EXTRA_EXMODS
|
||||
|
||||
|
||||
class JsonPayloadSerializer(messaging.NoOpSerializer):
|
||||
@staticmethod
|
||||
def serialize_entity(context, entity):
|
||||
return jsonutils.to_primitive(entity, convert_instances=True)
|
||||
|
||||
|
||||
class RequestContextSerializer(messaging.Serializer):
|
||||
|
||||
def __init__(self, base):
|
||||
|
||||
Reference in New Issue
Block a user