本文整理汇总了Python中oslo_messaging.JsonPayloadSerializer方法的典型用法代码示例。如果您正苦于以下问题:Python oslo_messaging.JsonPayloadSerializer方法的具体用法?Python oslo_messaging.JsonPayloadSerializer怎么用?Python oslo_messaging.JsonPayloadSerializer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oslo_messaging
的用法示例。
在下文中一共展示了oslo_messaging.JsonPayloadSerializer方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import JsonPayloadSerializer [as 别名]
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
示例2: init
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import JsonPayloadSerializer [as 别名]
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
示例3: __init__
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import JsonPayloadSerializer [as 别名]
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)
示例4: init
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import JsonPayloadSerializer [as 别名]
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)
示例5: init
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import JsonPayloadSerializer [as 别名]
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)
示例6: setup
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import JsonPayloadSerializer [as 别名]
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)
示例7: get_rpc_server
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import JsonPayloadSerializer [as 别名]
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)
示例8: get_rpc_client
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import JsonPayloadSerializer [as 别名]
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)
示例9: init
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import JsonPayloadSerializer [as 别名]
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'])