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)
def init(conf): global TRANSPORT, NOTIFIER exmods = get_allowed_exmods() TRANSPORT = messaging.get_transport(conf, allowed_remote_exmods=exmods, aliases=TRANSPORT_ALIASES) serializer = RequestContextSerializer(messaging.JsonPayloadSerializer()) NOTIFIER = messaging.Notifier(TRANSPORT, serializer=serializer)
def start(self): self.server = messaging.get_rpc_server( self.transport, self.consumer_target, endpoints=[YarmaEndpoint()], executor='threading', serializer=messaging.JsonPayloadSerializer() ) self.server.start()
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'])
def get_rpc_server(target, endpoint): """Return a configured oslo_messaging rpc server.""" serializer = RequestContextSerializer( oslo_messaging.JsonPayloadSerializer()) access_policy = dispatcher.DefaultRPCAccessPolicy return oslo_messaging.get_rpc_server(TRANSPORT, target, [endpoint], executor='eventlet', serializer=serializer, access_policy=access_policy)
def __init__(self, transport): super(YarmaPublisherService, self).__init__() self.publisher_target = messaging.Target( topic=cfg.CONF.default.publisher_queue, ) self.transport = transport self.server = messaging.RPCClient( self.transport, self.publisher_target, serializer=messaging.JsonPayloadSerializer() )
def init(conf): global TRANSPORT, NOTIFIER exmods = get_allowed_exmods() # TODO(yudazhao) remote url parameter, to use rabbit parameters in # cfg.CONF properties url = 'rabbit://*****:*****@192.168.33.1:5672/' TRANSPORT = messaging.get_transport(conf, url=url, allowed_remote_exmods=exmods, aliases=TRANSPORT_ALIASES) serializer = RequestContextSerializer(messaging.JsonPayloadSerializer()) NOTIFIER = messaging.Notifier(TRANSPORT, serializer=serializer)
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
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
def init(conf): global TRANSPORT, NOTIFICATION_TRANSPORT global SENSORS_NOTIFIER, VERSIONED_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()) SENSORS_NOTIFIER = messaging.Notifier(NOTIFICATION_TRANSPORT, serializer=serializer) if conf.notification_level is None: VERSIONED_NOTIFIER = messaging.Notifier(NOTIFICATION_TRANSPORT, serializer=serializer, driver='noop') else: VERSIONED_NOTIFIER = messaging.Notifier( NOTIFICATION_TRANSPORT, serializer=serializer, topics=CONF.versioned_notifications_topics)
def setup(url=None, optional=False): """Initialise the oslo_messaging layer.""" global NOTIFIER if url and url.startswith("fake://"): # NOTE(sileht): oslo_messaging fake driver uses time.sleep # for task switch, so we need to monkey_patch it eventlet.monkey_patch(time=True) if not TRANSPORT or not NOTIFICATIONS_TRANSPORT: setup_transports(url, optional) # In the fake driver, make the dict of exchanges local to each exchange # manager, instead of using the shared class attribute. Doing otherwise # breaks the unit tests. if url and url.startswith("fake://"): TRANSPORT._driver._exchange_manager._exchanges = {} if not NOTIFIER and NOTIFICATIONS_TRANSPORT: serializer = RequestContextSerializer( oslo_messaging.JsonPayloadSerializer()) NOTIFIER = oslo_messaging.Notifier(NOTIFICATIONS_TRANSPORT, serializer=serializer)
def get_rpc_client(**kwargs): """Return a configured oslo_messaging RPCClient.""" target = oslo_messaging.Target(**kwargs) serializer = RequestContextSerializer( oslo_messaging.JsonPayloadSerializer()) return oslo_messaging.RPCClient(TRANSPORT, target, serializer=serializer)
def init(conf): global TRANSPORT, NOTIFIER TRANSPORT = messaging.get_transport(conf) serializer = messaging.RequestContextSerializer( messaging.JsonPayloadSerializer()) NOTIFIER = messaging.Notifier(TRANSPORT, serializer=serializer)