Пример #1
0
def notify(context, message):
    """Sends a notification to the RabbitMQ"""
    if not context:
        context = req_context.get_admin_context()

    priority = message.get('priority',
                           CONF.healthnmon_default_notification_level)
    priority = priority.lower()

    # Construct topic name
# As the below code use to create multiple queues, it is removed
    topic_parts = []
    topic_parts.append('healthnmon_notification')
    topic_parts.append(priority)
    event_type = message.get('event_type', None)
    if event_type is not None:
        topic_parts.append(event_type)
        payload = message.get('payload', None)
        if payload is not None:
            entity_id = payload.get('entity_id', None)
            if entity_id is not None:
                topic_parts.append(entity_id)
    topic = '.'.join(topic_parts)

    rpc.notify(context, "healthnmon_notification", message)
Пример #2
0
def notify(context, message):
    """Sends a notification to the RabbitMQ"""
    if not context:
        context = req_context.get_admin_context()

    priority = message.get('priority',
                           CONF.healthnmon_default_notification_level)
    priority = priority.lower()

    # Construct topic name
    # As the below code use to create multiple queues, it is removed
    topic_parts = []
    topic_parts.append('healthnmon_notification')
    topic_parts.append(priority)
    event_type = message.get('event_type', None)
    if event_type is not None:
        topic_parts.append(event_type)
        payload = message.get('payload', None)
        if payload is not None:
            entity_id = payload.get('entity_id', None)
            if entity_id is not None:
                topic_parts.append(entity_id)
    topic = '.'.join(topic_parts)

    rpc.notify(context, "healthnmon_notification", message)
Пример #3
0
def notify(context, message):
    """Sends a notification via RPC"""
    if not context:
        context = req_context.get_admin_context()
    priority = message.get("priority", CONF.default_notification_level)
    priority = priority.lower()
    for topic in CONF.rpc_notifier2.topics:
        topic = "%s.%s" % (topic, priority)
        try:
            rpc.notify(context, topic, message, envelope=True)
        except Exception:
            LOG.exception(_("Could not send notification to %(topic)s. " "Payload=%(message)s"), locals())
Пример #4
0
def notify(context, message):
    """Sends a notification to the RabbitMQ"""
    if not context:
        context = nova.context.get_admin_context()
    priority = message.get('priority',
                           FLAGS.default_notification_level)
    priority = priority.lower()
    for topic in FLAGS.notification_topics:
        topic = '%s.%s' % (topic, priority)
        try:
            rpc.notify(context, topic, message)
        except Exception, e:
            LOG.exception(_("Could not send notification to %(topic)s. "
                            "Payload=%(message)s"), locals())
Пример #5
0
def notify(context, message):
    """Sends a notification to the RabbitMQ"""
    if not context:
        context = req_context.get_admin_context()
    priority = message.get('priority', CONF.default_notification_level)
    priority = priority.lower()
    for topic in CONF.notification_topics:
        topic = '%s.%s' % (topic, priority)
        try:
            rpc.notify(context, topic, message)
        except Exception, e:
            LOG.exception(
                _("Could not send notification to %(topic)s. "
                  "Payload=%(message)s"), locals())
    def testNotifyEntity_IdNone(self):
        message = {
            'priority': 'INFO',
            'event_type': 'LifeCycle.Vm.Reconfigured',
            'payload': {'entity_id': None},
            'message_id': '409e109d-41c0-4b75-9019-04aa3329c67b',
        }

        rpc.notify(mox.IgnoreArg(), 'healthnmon_notification',
                   mox.IgnoreArg()).AndReturn(None)
        self.mox.ReplayAll()
        self.assertEquals(
            healthnmon.notifier.rabbit_notifier.notify(self.context, message),
            None)
    def testNotifyEvent_TypeNone(self):
        message = {
            'priority': 'INFO',
            'event_type': None,
            'payload': {'entity_id': '024c1520-f836-47f7-3c91-df627096f8ab'},
            'message_id': '409e109d-41c0-4b75-9019-04aa3329c67b',
        }

        rpc.notify(mox.IgnoreArg(), 'healthnmon_notification',
                   mox.IgnoreArg()).AndReturn(None)
        self.mox.ReplayAll()
        self.assertEquals(
            healthnmon.notifier.rabbit_notifier.notify(self.context, message),
            None)
Пример #8
0
    def testNotifyEntity_IdNone(self):
        message = {
            'priority': 'INFO',
            'event_type': 'LifeCycle.Vm.Reconfigured',
            'payload': {'entity_id': None},
            'message_id': '409e109d-41c0-4b75-9019-04aa3329c67b',
        }

        rpc.notify(mox.IgnoreArg(), 'healthnmon_notification',
                   mox.IgnoreArg()).AndReturn(None)
        self.mox.ReplayAll()
        self.assertEquals(
            healthnmon.notifier.rabbit_notifier.notify(self.context, message),
            None)
Пример #9
0
    def testNotifyEvent_TypeNone(self):
        message = {
            'priority': 'INFO',
            'event_type': None,
            'payload': {'entity_id': '024c1520-f836-47f7-3c91-df627096f8ab'},
            'message_id': '409e109d-41c0-4b75-9019-04aa3329c67b',
        }

        rpc.notify(mox.IgnoreArg(), 'healthnmon_notification',
                   mox.IgnoreArg()).AndReturn(None)
        self.mox.ReplayAll()
        self.assertEquals(
            healthnmon.notifier.rabbit_notifier.notify(self.context, message),
            None)