2
2
# Copyright 2013-2014 eNovance
4
# Author: Mehdi Abaakouk <mehdi.abaakouk@enovance.com>
6
4
# Licensed under the Apache License, Version 2.0 (the "License"); you may
7
5
# not use this file except in compliance with the License. You may obtain
8
6
# a copy of the License at
17
15
"""Rest alarm notifier."""
20
from oslo.config import cfg
21
18
from oslo.serialization import jsonutils
19
from oslo_config import cfg
20
from oslo_context import context
23
22
import six.moves.urllib.parse as urlparse
25
24
from ceilometer.alarm import notifier
26
25
from ceilometer.i18n import _
27
from ceilometer.openstack.common import context
28
26
from ceilometer.openstack.common import log
30
28
LOG = log.getLogger(__name__)
57
55
"""Rest alarm notifier."""
60
def notify(action, alarm_id, alarm_name, previous, current, reason,
61
reason_data, headers=None):
58
def notify(action, alarm_id, alarm_name, severity, previous,
59
current, reason, reason_data, headers=None):
62
60
headers = headers or {}
63
61
if not headers.get('x-openstack-request-id'):
64
62
headers['x-openstack-request-id'] = context.generate_request_id()
68
66
"%(previous)s to %(current)s with action %(action)s because "
69
67
"%(reason)s. request-id: %(request_id)s ") %
70
68
({'alarm_name': alarm_name, 'alarm_id': alarm_id,
71
'previous': previous, 'current': current,
72
'action': action, 'reason': reason,
69
'severity': severity, 'previous': previous,
70
'current': current, 'action': action, 'reason': reason,
73
71
'request_id': headers['x-openstack-request-id']}))
74
72
body = {'alarm_name': alarm_name, 'alarm_id': alarm_id,
75
'previous': previous, 'current': current,
76
'reason': reason, 'reason_data': reason_data}
73
'severity': severity, 'previous': previous,
74
'current': current, 'reason': reason,
75
'reason_data': reason_data}
77
76
headers['content-type'] = 'application/json'
78
77
kwargs = {'data': jsonutils.dumps(body),
79
78
'headers': headers}