当前位置: 首页>>代码示例>>Python>>正文


Python oslo_messaging.get_notification_listener方法代码示例

本文整理汇总了Python中oslo_messaging.get_notification_listener方法的典型用法代码示例。如果您正苦于以下问题:Python oslo_messaging.get_notification_listener方法的具体用法?Python oslo_messaging.get_notification_listener怎么用?Python oslo_messaging.get_notification_listener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oslo_messaging的用法示例。


在下文中一共展示了oslo_messaging.get_notification_listener方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import get_notification_listener [as 别名]
def main():
    if len(sys.argv) < 2:
        print("Supply an exchange")
        sys.exit(0)

    exchange = sys.argv[1]
    pool = sys.argv[2] if len(sys.argv) > 2 else None

    transport = oslo_messaging.get_notification_transport(
        cfg.CONF,
        url='rabbit://%s:%s@%s' % (username, password, host))
    targets = [oslo_messaging.Target(topic=topic, exchange=exchange)]
    endpoints = [EP()]
    oslo_listener = oslo_messaging.get_notification_listener(
        transport, targets, endpoints, pool=pool, executor='threading')
    try:
        print("Started")
        oslo_listener.start()
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        print("Stopping")
        oslo_listener.stop()
        oslo_listener.wait() 
开发者ID:openstack,项目名称:searchlight,代码行数:26,代码来源:listener.py

示例2: start

# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import get_notification_listener [as 别名]
def start(self):
        super(ListenerService, self).start()
        transport = oslo_messaging.get_notification_transport(CONF)
        targets = [
            oslo_messaging.Target(topic=pl_topic, exchange=pl_exchange)
            for pl_topic, pl_exchange in self.topics_exchanges_set
        ]
        endpoints = [
            NotificationEndpoint(self.plugins, PipelineManager(self.plugins))
        ]
        listener = oslo_messaging.get_notification_listener(
            transport,
            targets,
            endpoints,
            executor='threading',
            pool=CONF.listener.notifications_pool)

        listener.start()
        self.listeners.append(listener) 
开发者ID:openstack,项目名称:searchlight,代码行数:21,代码来源:listener.py

示例3: get_notification_listener

# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import get_notification_listener [as 别名]
def get_notification_listener(targets, endpoints, serializer=None, pool=None):
    if NOTIFICATION_TRANSPORT is None:
        raise AssertionError("'NOTIFICATION_TRANSPORT' must not be None")
    if serializer is None:
        serializer = JsonPayloadSerializer()
    return messaging.get_notification_listener(
        NOTIFICATION_TRANSPORT,
        targets,
        endpoints,
        executor='eventlet',
        pool=pool,
        serializer=serializer
    ) 
开发者ID:openstack,项目名称:designate,代码行数:15,代码来源:rpc.py

示例4: get_notification_listener

# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import get_notification_listener [as 别名]
def get_notification_listener(transport, targets, endpoints,
                              allow_requeue=False):
    """Return a configured oslo_messaging notification listener."""
    return oslo_msg.get_notification_listener(
        transport, targets, endpoints, allow_requeue=allow_requeue) 
开发者ID:openstack,项目名称:vitrage,代码行数:7,代码来源:messaging.py

示例5: build_notification_handler

# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import get_notification_listener [as 别名]
def build_notification_handler(self, topic_names, endpoints=()):
        serializer = rpc.RequestContextSerializer(rpc.JsonPayloadSerializer())
        targets = []
        for topic in topic_names:
            kwargs = {}
            if '.' in topic:
                exchange, topic = topic.split('.')
                kwargs['exchange'] = exchange
            kwargs['topic'] = topic
            targets.append(om.Target(**kwargs))
        return om.get_notification_listener(
            self.notification_transport, targets, endpoints,
            executor='eventlet', serializer=serializer,
            allow_requeue=False, pool=CONF.host) 
开发者ID:openstack,项目名称:watcher,代码行数:16,代码来源:service.py

示例6: ListenerProc

# 需要导入模块: import oslo_messaging [as 别名]
# 或者: from oslo_messaging import get_notification_listener [as 别名]
def ListenerProc(exchange, project_id, cluster_id, recover_action):
    """Thread procedure for running an event listener.

    :param exchange: The control exchange for a target service.
    :param project_id: The ID of the project to filter.
    :param cluster_id: The ID of the cluster to filter.
    :param recover_action: The health policy action name.
    """
    transport = messaging.get_notification_transport(cfg.CONF)

    if exchange == cfg.CONF.health_manager.nova_control_exchange:
        endpoint = nova_endpoint.NovaNotificationEndpoint(
            project_id, cluster_id, recover_action
        )

    else:
        endpoint = heat_endpoint.HeatNotificationEndpoint(
            project_id, cluster_id, recover_action
        )

    listener = messaging.get_notification_listener(
        transport, [endpoint.target], [endpoint], executor='threading',
        pool='senlin-listeners'
    )

    listener.start() 
开发者ID:openstack,项目名称:senlin,代码行数:28,代码来源:health_manager.py


注:本文中的oslo_messaging.get_notification_listener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。