Python oslo_messaging.JsonPayloadSerializer() Examples
The following are 9
code examples of oslo_messaging.JsonPayloadSerializer().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
oslo_messaging
, or try the search function
.
Example #1
Source File: rpc.py From manila with Apache License 2.0 | 6 votes |
def init(conf): global TRANSPORT, NOTIFICATION_TRANSPORT, NOTIFIER exmods = get_allowed_exmods() TRANSPORT = messaging.get_rpc_transport(conf, allowed_remote_exmods=exmods) NOTIFICATION_TRANSPORT = messaging.get_notification_transport( conf, allowed_remote_exmods=exmods) if utils.notifications_enabled(conf): json_serializer = messaging.JsonPayloadSerializer() serializer = RequestContextSerializer(json_serializer) NOTIFIER = messaging.Notifier(NOTIFICATION_TRANSPORT, serializer=serializer) else: NOTIFIER = utils.DO_NOTHING
Example #2
Source File: rpc.py From karbor with Apache License 2.0 | 6 votes |
def init(conf): global TRANSPORT, NOTIFICATION_TRANSPORT, NOTIFIER exmods = get_allowed_exmods() TRANSPORT = messaging.get_rpc_transport(conf, allowed_remote_exmods=exmods) NOTIFICATION_TRANSPORT = messaging.get_notification_transport( conf, allowed_remote_exmods=exmods) # get_notification_transport has loaded oslo_messaging_notifications config # group, so we can now check if notifications are actually enabled. if utils.notifications_enabled(conf): json_serializer = messaging.JsonPayloadSerializer() serializer = RequestContextSerializer(json_serializer) NOTIFIER = messaging.Notifier(NOTIFICATION_TRANSPORT, serializer=serializer) else: NOTIFIER = utils.DO_NOTHING
Example #3
Source File: broker.py From galaxia with Apache License 2.0 | 5 votes |
def __init__(self, topic, host, handler): serializer = messaging.RequestContextSerializer( messaging.JsonPayloadSerializer()) transport = messaging.get_transport(cfg.CONF) target = messaging.Target(topic=topic, server=host) self.rpc_server = messaging.get_rpc_server(transport, target, handler, serializer=serializer)
Example #4
Source File: rpc.py From tacker with Apache License 2.0 | 5 votes |
def init(conf): global TRANSPORT, NOTIFICATION_TRANSPORT, NOTIFIER exmods = get_allowed_exmods() TRANSPORT = oslo_messaging.get_rpc_transport(conf, allowed_remote_exmods=exmods) NOTIFICATION_TRANSPORT = oslo_messaging.get_notification_transport( conf, allowed_remote_exmods=exmods) json_serializer = oslo_messaging.JsonPayloadSerializer() serializer = RequestContextSerializer(json_serializer) NOTIFIER = oslo_messaging.Notifier(NOTIFICATION_TRANSPORT, serializer=serializer)
Example #5
Source File: rpc.py From watcher with Apache License 2.0 | 5 votes |
def init(conf): global TRANSPORT, NOTIFICATION_TRANSPORT, NOTIFIER exmods = get_allowed_exmods() TRANSPORT = messaging.get_rpc_transport( conf, allowed_remote_exmods=exmods) NOTIFICATION_TRANSPORT = messaging.get_notification_transport( conf, allowed_remote_exmods=exmods) serializer = RequestContextSerializer(JsonPayloadSerializer()) if not conf.notification_level: NOTIFIER = messaging.Notifier( NOTIFICATION_TRANSPORT, serializer=serializer, driver='noop') else: NOTIFIER = messaging.Notifier(NOTIFICATION_TRANSPORT, serializer=serializer)
Example #6
Source File: messaging.py From senlin with Apache License 2.0 | 5 votes |
def setup(url=None, optional=False): """Initialise the oslo_messaging layer.""" global TRANSPORT, GLOBAL_TRANSPORT, NOTIFIER if url and url.startswith("fake://"): # NOTE: oslo_messaging fake driver uses time.sleep # for task switch, so we need to monkey_patch it eventlet.monkey_patch(time=True) messaging.set_transport_defaults('senlin') if not TRANSPORT: exmods = ['senlin.common.exception'] try: TRANSPORT = messaging.get_rpc_transport( cfg.CONF, url, allowed_remote_exmods=exmods) except messaging.InvalidTransportURL as e: TRANSPORT = None if not optional or e.url: # NOTE: oslo_messaging is configured but unloadable # so reraise the exception raise if not NOTIFIER: exmods = ['senlin.common.exception'] try: NOTIFICATION_TRANSPORT = messaging.get_notification_transport( cfg.CONF, allowed_remote_exmods=exmods) except Exception: raise serializer = RequestContextSerializer(JsonPayloadSerializer()) NOTIFIER = messaging.Notifier(NOTIFICATION_TRANSPORT, serializer=serializer, topics=cfg.CONF.notification_topics)
Example #7
Source File: messaging.py From senlin with Apache License 2.0 | 5 votes |
def get_rpc_server(target, endpoint, serializer=None): """Return a configured oslo_messaging rpc server.""" if serializer is None: serializer = JsonPayloadSerializer() serializer = RequestContextSerializer(serializer) return messaging.get_rpc_server(TRANSPORT, target, [endpoint], executor='eventlet', serializer=serializer)
Example #8
Source File: messaging.py From senlin with Apache License 2.0 | 5 votes |
def get_rpc_client(topic, server, serializer=None): """Return a configured oslo_messaging RPCClient.""" target = messaging.Target(topic=topic, server=server, version=consts.RPC_API_VERSION_BASE) if serializer is None: serializer = JsonPayloadSerializer() serializer = RequestContextSerializer(serializer) return messaging.RPCClient(TRANSPORT, target, serializer=serializer)
Example #9
Source File: rpc.py From cyborg with Apache License 2.0 | 5 votes |
def init(conf): global TRANSPORT, NOTIFICATION_TRANSPORT, NOTIFIER exmods = get_allowed_exmods() TRANSPORT = messaging.get_rpc_transport(conf, allowed_remote_exmods=exmods) NOTIFICATION_TRANSPORT = messaging.get_notification_transport( conf, allowed_remote_exmods=exmods) serializer = RequestContextSerializer(messaging.JsonPayloadSerializer()) NOTIFIER = messaging.Notifier(NOTIFICATION_TRANSPORT, serializer=serializer, topics=['notifications'])