本文整理汇总了Python中oslo_messaging.get_rpc_transport方法的典型用法代码示例。如果您正苦于以下问题:Python oslo_messaging.get_rpc_transport方法的具体用法?Python oslo_messaging.get_rpc_transport怎么用?Python oslo_messaging.get_rpc_transport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oslo_messaging
的用法示例。
在下文中一共展示了oslo_messaging.get_rpc_transport方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import get_rpc_transport [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: get_transport
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import get_rpc_transport [as 别名]
def get_transport(url=None, optional=False, cache=True, rpc=False):
"""Initialise the oslo_messaging layer."""
global TRANSPORTS, DEFAULT_URL
cache_key = url or DEFAULT_URL + '_rpc' if rpc else ''
transport = TRANSPORTS.get(cache_key)
if not transport or not cache:
try:
if rpc:
transport = oslo_msg.get_rpc_transport(CONF, url)
else:
transport = oslo_msg.get_notification_transport(CONF, url)
except oslo_msg.InvalidTransportURL as e:
if not optional or e.url:
# NOTE(sileht): oslo_messaging is configured but unloadable
# so reraise the exception
raise
return None
else:
if cache:
TRANSPORTS[cache_key] = transport
return transport
示例3: get_transport
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import get_rpc_transport [as 别名]
def get_transport(url=None, optional=False, cache=True):
"""Initialise the oslo_messaging layer."""
global TRANSPORTS, DEFAULT_URL
cache_key = url or DEFAULT_URL
transport = TRANSPORTS.get(cache_key)
if not transport or not cache:
try:
transport = oslo_messaging.get_rpc_transport(cfg.CONF, url)
except (oslo_messaging.InvalidTransportURL,
oslo_messaging.DriverLoadFailure):
if not optional or url:
# NOTE(sileht): oslo_messaging is configured but unloadable
# so reraise the exception
raise
return None
else:
if cache:
TRANSPORTS[cache_key] = transport
return transport
示例4: init
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import get_rpc_transport [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
示例5: init
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import get_rpc_transport [as 别名]
def init(conf, rpc_ext_mods=None):
"""Initialize the global RPC objects.
:param conf: The oslo conf to use for initialization.
:param rpc_ext_mods: Exception modules to expose via RPC.
:returns: None.
"""
global TRANSPORT, NOTIFICATION_TRANSPORT, NOTIFIER
if rpc_ext_mods is None:
rpc_ext_mods = _DFT_EXMODS
else:
rpc_ext_mods = list(set(rpc_ext_mods + _DFT_EXMODS))
TRANSPORT = oslo_messaging.get_rpc_transport(
conf, allowed_remote_exmods=rpc_ext_mods)
NOTIFICATION_TRANSPORT = oslo_messaging.get_notification_transport(
conf, allowed_remote_exmods=rpc_ext_mods)
serializer = RequestContextSerializer()
NOTIFIER = oslo_messaging.Notifier(NOTIFICATION_TRANSPORT,
serializer=serializer)
示例6: init
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import get_rpc_transport [as 别名]
def init(conf):
global TRANSPORT
exmods = get_allowed_exmods()
TRANSPORT = messaging.get_rpc_transport(
conf, allowed_remote_exmods=exmods)
示例7: __init__
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import get_rpc_transport [as 别名]
def __init__(self, topic, server, endpoints, binary):
super(Service, self).__init__()
serializer = _init_serializer()
transport = messaging.get_rpc_transport(CONF)
access_policy = dispatcher.DefaultRPCAccessPolicy
# TODO(asalkeld) add support for version='x.y'
target = messaging.Target(topic=topic, server=server)
self.endpoints = endpoints
self._server = messaging.get_rpc_server(transport, target, endpoints,
executor='eventlet',
serializer=serializer,
access_policy=access_policy)
self.binary = binary
profiler.setup(binary, CONF.host)
示例8: __init__
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import get_rpc_transport [as 别名]
def __init__(self, amp_id):
super(AmphoraUpdateController, self).__init__()
if CONF.api_settings.default_provider_driver == constants.AMPHORAV2:
topic = constants.TOPIC_AMPHORA_V2
version = "2.0"
else:
topic = cfg.CONF.oslo_messaging.topic
version = "1.0"
self.transport = messaging.get_rpc_transport(cfg.CONF)
self.target = messaging.Target(
namespace=constants.RPC_NAMESPACE_CONTROLLER_AGENT,
topic=topic, version=version, fanout=False)
self.client = messaging.RPCClient(self.transport, target=self.target)
self.amp_id = amp_id
示例9: _fake_create_transport
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import get_rpc_transport [as 别名]
def _fake_create_transport(self, url):
if url not in self._buses:
self._buses[url] = messaging.get_rpc_transport(
cfg.CONF,
url=url)
return self._buses[url]
示例10: create_transport
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import get_rpc_transport [as 别名]
def create_transport(url):
return messaging.get_rpc_transport(cfg.CONF, url=url)
示例11: create_transport
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import get_rpc_transport [as 别名]
def create_transport(url):
exmods = get_allowed_exmods()
return messaging.get_rpc_transport(CONF,
url=url,
allowed_remote_exmods=exmods)
示例12: init
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import get_rpc_transport [as 别名]
def init(conf):
global TRANSPORT, NOTIFIER
exmods = get_allowed_exmods()
TRANSPORT = messaging.get_rpc_transport(conf,
allowed_remote_exmods=exmods)
serializer = RequestContextSerializer(JsonPayloadSerializer())
NOTIFIER = messaging.Notifier(TRANSPORT, serializer=serializer)
示例13: __init__
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import get_rpc_transport [as 别名]
def __init__(self, topic, server, handlers, binary):
super(Service, self).__init__()
serializer = _init_serializer()
transport = messaging.get_rpc_transport(CONF)
# TODO(asalkeld) add support for version='x.y'
access_policy = dispatcher.DefaultRPCAccessPolicy
target = messaging.Target(topic=topic, server=server)
self._server = messaging.get_rpc_server(transport, target, handlers,
executor='eventlet',
serializer=serializer,
access_policy=access_policy)
self.binary = binary
profiler.setup(binary, CONF.host)
示例14: get_rpc_transport
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import get_rpc_transport [as 别名]
def get_rpc_transport(url=None, optional=False, cache=True):
return get_transport(url, optional, cache, rpc=True)
示例15: init_action_rpc
# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import get_rpc_transport [as 别名]
def init_action_rpc(conf):
global TRANSPORT
TRANSPORT = oslo_messaging.get_rpc_transport(conf)