Exemple #1
0
 def setUp(self):
     super(APiTest, self).setUp()
     self.flags(healthnmon_default_notification_level='INFO',
                healthnmon_notification_drivers=[
                'healthnmon.notifier.rabbit_notifier'
                ])
     self.context = context.get_admin_context()
 def setUp(self):
     super(RabbitNotifierTest, self).setUp()
     self.flags(
         healthnmon_default_notification_level=
         DEFAULT_NOTIFICATION_PRIORITY)
     self.mox.StubOutWithMock(rpc, 'notify')
     self.context = context.get_admin_context()
Exemple #3
0
    def process_request(self, request):
        request.environ['HTTP_X_SERVICE_NAME'] = \
            self.service_name or request.host
        payload = {
            'request': self.environ_to_dict(request.environ),
        }

        api.notify(context.get_admin_context(),
                   api.publisher_id(os.path.basename(sys.argv[0])),
                   'http.request', api.INFO, payload)
Exemple #4
0
    def process_request(self, request):
        request.environ['HTTP_X_SERVICE_NAME'] = \
            self.service_name or request.host
        payload = {
            'request': self.environ_to_dict(request.environ),
        }

        api.notify(context.get_admin_context(),
                   api.publisher_id(os.path.basename(sys.argv[0])),
                   'http.request',
                   api.INFO,
                   payload)
Exemple #5
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())
Exemple #6
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())
Exemple #7
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())
Exemple #8
0
    def process_response(self, request, response,
                         exception=None, traceback=None):
        payload = {
            'request': self.environ_to_dict(request.environ),
        }

        if response:
            payload['response'] = {
                'status': response.status,
                'headers': response.headers,
            }

        if exception:
            payload['exception'] = {
                'value': repr(exception),
                'traceback': tb.format_tb(traceback)
            }

        api.notify(context.get_admin_context(),
                   api.publisher_id(os.path.basename(sys.argv[0])),
                   'http.response',
                   api.INFO,
                   payload)
Exemple #9
0
    def process_response(self,
                         request,
                         response,
                         exception=None,
                         traceback=None):
        payload = {
            'request': self.environ_to_dict(request.environ),
        }

        if response:
            payload['response'] = {
                'status': response.status,
                'headers': response.headers,
            }

        if exception:
            payload['exception'] = {
                'value': repr(exception),
                'traceback': tb.format_tb(traceback)
            }

        api.notify(context.get_admin_context(),
                   api.publisher_id(os.path.basename(sys.argv[0])),
                   'http.response', api.INFO, payload)
Exemple #10
0
 def setUp(self):
     super(LogNotifierTest, self).setUp()
     self.context = context.get_admin_context()
     self.flags(healthnmon_default_notification_level='INFO')
 def setUp(self):
     super(LogNotifierTest, self).setUp()
     self.context = context.get_admin_context()
     self.flags(healthnmon_default_notification_level='INFO')
 def setUp(self):
     self.flags(healthnmon_default_notification_level='INFO')
     super(RabbitNotifierTest, self).setUp()
     self.mox.StubOutWithMock(rpc, 'notify')
     self.context = context.get_admin_context()