Ejemplo n.º 1
0
def get_notification_transport(conf,
                               url=None,
                               allowed_remote_exmods=None,
                               aliases=None):
    """A factory method for Transport objects for notifications.

    This method should be used for notifications, in case notifications are
    being sent over a different message bus than normal messaging
    functionality; for example, using a different driver, or with different
    access permissions.

    If no transport URL is provided, the URL in the notifications section of
    the config file will be used.  If that URL is also absent, the same
    transport as specified in the messaging section will be used.

    If a transport URL is provided, then this function works exactly the same
    as get_transport.

    :param conf: the user configuration
    :type conf: cfg.ConfigOpts
    :param url: a transport URL
    :type url: str or TransportURL
    :param allowed_remote_exmods: a list of modules which a client using this
                                  transport will deserialize remote exceptions
                                  from
    :type allowed_remote_exmods: list
    :param aliases: A map of transport alias to transport name
    :type aliases: dict
    """
    conf.register_opts(_notifier_opts, group='oslo_messaging_notifications')
    if url is None:
        url = conf.oslo_messaging_notifications.transport_url
    return msg_transport.get_transport(conf, url, allowed_remote_exmods,
                                       aliases)
Ejemplo n.º 2
0
def get_notification_transport(conf, url=None,
                               allowed_remote_exmods=None, aliases=None):
    if url is None:
        conf.register_opts(_notifier_opts)
        url = conf.notification_transport_url
    return msg_transport.get_transport(conf, url,
                                       allowed_remote_exmods, aliases)
Ejemplo n.º 3
0
def get_notification_transport(conf, url=None,
                               allowed_remote_exmods=None, aliases=None):
    """A factory method for Transport objects for notifications.

    This method should be used for notifications, in case notifications are
    being sent over a different message bus than normal messaging
    functionality; for example, using a different driver, or with different
    access permissions.

    If no transport URL is provided, the URL in the notifications section of
    the config file will be used.  If that URL is also absent, the same
    transport as specified in the messaging section will be used.

    If a transport URL is provided, then this function works exactly the same
    as get_transport.

    :param conf: the user configuration
    :type conf: cfg.ConfigOpts
    :param url: a transport URL
    :type url: str or TransportURL
    :param allowed_remote_exmods: a list of modules which a client using this
                                  transport will deserialize remote exceptions
                                  from
    :type allowed_remote_exmods: list
    :param aliases: A map of transport alias to transport name
    :type aliases: dict
    """
    conf.register_opts(_notifier_opts,
                       group='oslo_messaging_notifications')
    if url is None:
        url = conf.oslo_messaging_notifications.transport_url
    return msg_transport.get_transport(conf, url,
                                       allowed_remote_exmods, aliases)
Ejemplo n.º 4
0
def get_notification_transport(conf, url=None,
                               allowed_remote_exmods=None, aliases=None):
    conf.register_opts(_notifier_opts,
                       group='oslo_messaging_notifications')
    if url is None:
        url = conf.oslo_messaging_notifications.transport_url
    return msg_transport.get_transport(conf, url,
                                       allowed_remote_exmods, aliases)
Ejemplo n.º 5
0
def get_notification_transport(conf, url=None,
                               allowed_remote_exmods=None, aliases=None):
    conf.register_opts(_notifier_opts,
                       group='oslo_messaging_notifications')
    if url is None:
        url = conf.oslo_messaging_notifications.transport_url
    return msg_transport.get_transport(conf, url,
                                       allowed_remote_exmods, aliases)
Ejemplo n.º 6
0
 def __init__(self, url, publisher_id=None, driver=None,
              topic=None, serializer=None):
     self.notifier = notifier.Notifier(
         transport.get_transport(self.CONF, url),
         publisher_id, driver,
         topic,
         serializer() if serializer else None)
     logging.Handler.__init__(self)
Ejemplo n.º 7
0
 def setUp(self):
     super(NotificationTest, self).setUp()
     self.exchange = kombu.Exchange('heat', 'topic', durable=False)
     queue = kombu.Queue(exchange=self.exchange,
                         routing_key='notifications.info',
                         exclusive=True)
     self.conn = kombu.Connection(
         get_url(transport.get_transport(cfg.CONF).conf))
     self.ch = self.conn.channel()
     self.queue = queue(self.ch)
     self.queue.declare()
Ejemplo n.º 8
0
 def setUp(self):
     super(NotificationTest, self).setUp()
     self.exchange = kombu.Exchange('heat', 'topic', durable=False)
     queue = kombu.Queue(exchange=self.exchange,
                         routing_key='notifications.info',
                         exclusive=True)
     self.conn = kombu.Connection(get_url(
         transport.get_transport(cfg.CONF).conf))
     self.ch = self.conn.channel()
     self.queue = queue(self.ch)
     self.queue.declare()
Ejemplo n.º 9
0
 def __init__(self,
              url,
              publisher_id=None,
              driver=None,
              topic=None,
              serializer=None):
     self.notifier = notifier.Notifier(
         transport.get_transport(self.CONF, url), publisher_id, driver,
         topic,
         serializer() if serializer else None)
     logging.Handler.__init__(self)
Ejemplo n.º 10
0
def start_listener(conf, exchange, topic, endpoints):
    """Starts up a notification listener."""
    trans = transport.get_transport(conf)
    targets = [target.Target(exchange=exchange, topic=topic)]
    pool_name = get_pool_name(exchange)

    notification_listener = listener.get_notification_listener(
        trans,
        targets,
        endpoints,
        executor='threading',
        allow_requeue=False,
        pool=pool_name)
    notification_listener.start()

    return notification_listener
Ejemplo n.º 11
0
def start_listener(conf, exchange, topic, endpoints):
    """Starts up a notification listener."""
    trans = transport.get_transport(conf)
    targets = [target.Target(exchange=exchange, topic=topic)]
    pool_name = get_pool_name(exchange)

    notification_listener = listener.get_notification_listener(
        trans,
        targets,
        endpoints,
        executor='threading',
        allow_requeue=False,
        pool=pool_name
    )
    notification_listener.start()

    return notification_listener