notifier: move from alarm to top-level

Also move some options for the REST notifier from the alarm group to the
default one.

Change-Id: Ic6ae4677ec0968ddf58e68eaf06f59204f52d56b
This commit is contained in:
Julien Danjou 2015-07-21 16:30:12 +02:00
parent ca8f0cc24a
commit 795bdb80b6
12 changed files with 34 additions and 35 deletions

View File

@ -16,8 +16,8 @@
from oslo_log import log from oslo_log import log
from aodh.alarm import notifier
from aodh.i18n import _ from aodh.i18n import _
from aodh import notifier
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)

View File

@ -22,33 +22,37 @@ from oslo_serialization import jsonutils
import requests import requests
import six.moves.urllib.parse as urlparse import six.moves.urllib.parse as urlparse
from aodh.alarm import notifier
from aodh.i18n import _ from aodh.i18n import _
from aodh import notifier
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
OPTS = [ OPTS = [
cfg.StrOpt('rest_notifier_certificate_file', cfg.StrOpt('rest_notifier_certificate_file',
default='', default='',
deprecated_group="alarm",
help='SSL Client certificate for REST notifier.' help='SSL Client certificate for REST notifier.'
), ),
cfg.StrOpt('rest_notifier_certificate_key', cfg.StrOpt('rest_notifier_certificate_key',
default='', default='',
deprecated_group="alarm",
help='SSL Client private key for REST notifier.' help='SSL Client private key for REST notifier.'
), ),
cfg.BoolOpt('rest_notifier_ssl_verify', cfg.BoolOpt('rest_notifier_ssl_verify',
default=True, default=True,
deprecated_group="alarm",
help='Whether to verify the SSL Server certificate when ' help='Whether to verify the SSL Server certificate when '
'calling alarm action.' 'calling alarm action.'
), ),
cfg.IntOpt('rest_notifier_max_retries', cfg.IntOpt('rest_notifier_max_retries',
default=0, default=0,
deprecated_group="alarm",
help='Number of retries for REST notifier', help='Number of retries for REST notifier',
), ),
] ]
cfg.CONF.register_opts(OPTS, group="alarm") cfg.CONF.register_opts(OPTS)
class RestAlarmNotifier(notifier.AlarmNotifier): class RestAlarmNotifier(notifier.AlarmNotifier):
@ -78,14 +82,14 @@ class RestAlarmNotifier(notifier.AlarmNotifier):
'headers': headers} 'headers': headers}
if action.scheme == 'https': if action.scheme == 'https':
default_verify = int(cfg.CONF.alarm.rest_notifier_ssl_verify) default_verify = int(cfg.CONF.rest_notifier_ssl_verify)
options = urlparse.parse_qs(action.query) options = urlparse.parse_qs(action.query)
verify = bool(int(options.get('aodh-alarm-ssl-verify', verify = bool(int(options.get('aodh-alarm-ssl-verify',
[default_verify])[-1])) [default_verify])[-1]))
kwargs['verify'] = verify kwargs['verify'] = verify
cert = cfg.CONF.alarm.rest_notifier_certificate_file cert = cfg.CONF.rest_notifier_certificate_file
key = cfg.CONF.alarm.rest_notifier_certificate_key key = cfg.CONF.rest_notifier_certificate_key
if cert: if cert:
kwargs['cert'] = (cert, key) if key else cert kwargs['cert'] = (cert, key) if key else cert
@ -93,7 +97,7 @@ class RestAlarmNotifier(notifier.AlarmNotifier):
# library. However, there's no interval between retries in urllib3 # library. However, there's no interval between retries in urllib3
# implementation. It will be better to put some interval between # implementation. It will be better to put some interval between
# retries (future work). # retries (future work).
max_retries = cfg.CONF.alarm.rest_notifier_max_retries max_retries = cfg.CONF.rest_notifier_max_retries
session = requests.Session() session = requests.Session()
session.mount(action.geturl(), session.mount(action.geturl(),
requests.adapters.HTTPAdapter(max_retries=max_retries)) requests.adapters.HTTPAdapter(max_retries=max_retries))

View File

@ -14,7 +14,7 @@
# under the License. # under the License.
"""Test alarm notifier.""" """Test alarm notifier."""
from aodh.alarm import notifier from aodh import notifier
class TestAlarmNotifier(notifier.AlarmNotifier): class TestAlarmNotifier(notifier.AlarmNotifier):

View File

@ -16,8 +16,8 @@
from six.moves.urllib import parse from six.moves.urllib import parse
from aodh.alarm.notifier import rest
from aodh import keystone_client from aodh import keystone_client
from aodh.notifier import rest
class TrustRestAlarmNotifier(rest.RestAlarmNotifier): class TrustRestAlarmNotifier(rest.RestAlarmNotifier):

View File

@ -13,11 +13,11 @@
# under the License. # under the License.
import itertools import itertools
import aodh.alarm.notifier.rest
import aodh.api import aodh.api
import aodh.api.app import aodh.api.app
import aodh.api.controllers.v2.alarms import aodh.api.controllers.v2.alarms
import aodh.coordination import aodh.coordination
import aodh.notifier.rest
import aodh.rpc import aodh.rpc
import aodh.service import aodh.service
import aodh.storage import aodh.storage
@ -27,12 +27,12 @@ def list_opts():
return [ return [
('DEFAULT', ('DEFAULT',
itertools.chain(aodh.api.app.OPTS, itertools.chain(aodh.api.app.OPTS,
aodh.notifier.rest.OPTS,
aodh.service.OPTS, aodh.service.OPTS,
aodh.rpc.OPTS, aodh.rpc.OPTS,
aodh.storage.OLD_OPTS,)), aodh.storage.OLD_OPTS,)),
('alarm', ('alarm',
itertools.chain(aodh.alarm.notifier.rest.OPTS, itertools.chain(aodh.alarm.evaluator.gnocchi.OPTS,
aodh.alarm.evaluator.gnocchi.OPTS,
aodh.api.controllers.v2.alarms.ALARM_API_OPTS)), aodh.api.controllers.v2.alarms.ALARM_API_OPTS)),
('api', ('api',
itertools.chain(aodh.api.OPTS, itertools.chain(aodh.api.OPTS,

View File

@ -221,7 +221,7 @@ class AlarmEvaluationService(AlarmService, os_service.Service):
class AlarmNotifierService(os_service.Service): class AlarmNotifierService(os_service.Service):
NOTIFIER_EXTENSIONS_NAMESPACE = "aodh.alarm.notifier" NOTIFIER_EXTENSIONS_NAMESPACE = "aodh.notifier"
def __init__(self): def __init__(self):
super(AlarmNotifierService, self).__init__() super(AlarmNotifierService, self).__init__()

View File

@ -127,8 +127,7 @@ class TestAlarmNotifier(tests_base.BaseTestCase):
action = 'https://host/action' action = 'https://host/action'
certificate = "/etc/ssl/cert/whatever.pem" certificate = "/etc/ssl/cert/whatever.pem"
self.CONF.set_override("rest_notifier_certificate_file", certificate, self.CONF.set_override("rest_notifier_certificate_file", certificate)
group='alarm')
with mock.patch('eventlet.spawn_n', self._fake_spawn_n): with mock.patch('eventlet.spawn_n', self._fake_spawn_n):
with mock.patch.object(requests.Session, 'post') as poster: with mock.patch.object(requests.Session, 'post') as poster:
@ -146,10 +145,8 @@ class TestAlarmNotifier(tests_base.BaseTestCase):
certificate = "/etc/ssl/cert/whatever.pem" certificate = "/etc/ssl/cert/whatever.pem"
key = "/etc/ssl/cert/whatever.key" key = "/etc/ssl/cert/whatever.key"
self.CONF.set_override("rest_notifier_certificate_file", certificate, self.CONF.set_override("rest_notifier_certificate_file", certificate)
group='alarm') self.CONF.set_override("rest_notifier_certificate_key", key)
self.CONF.set_override("rest_notifier_certificate_key", key,
group='alarm')
with mock.patch('eventlet.spawn_n', self._fake_spawn_n): with mock.patch('eventlet.spawn_n', self._fake_spawn_n):
with mock.patch.object(requests.Session, 'post') as poster: with mock.patch.object(requests.Session, 'post') as poster:
@ -165,8 +162,7 @@ class TestAlarmNotifier(tests_base.BaseTestCase):
def test_notify_alarm_rest_action_with_ssl_verify_disable_by_cfg(self): def test_notify_alarm_rest_action_with_ssl_verify_disable_by_cfg(self):
action = 'https://host/action' action = 'https://host/action'
self.CONF.set_override("rest_notifier_ssl_verify", False, self.CONF.set_override("rest_notifier_ssl_verify", False)
group='alarm')
with mock.patch('eventlet.spawn_n', self._fake_spawn_n): with mock.patch('eventlet.spawn_n', self._fake_spawn_n):
with mock.patch.object(requests.Session, 'post') as poster: with mock.patch.object(requests.Session, 'post') as poster:
@ -196,8 +192,7 @@ class TestAlarmNotifier(tests_base.BaseTestCase):
def test_notify_alarm_rest_action_with_ssl_verify_enable_by_user(self): def test_notify_alarm_rest_action_with_ssl_verify_enable_by_user(self):
action = 'https://host/action?aodh-alarm-ssl-verify=1' action = 'https://host/action?aodh-alarm-ssl-verify=1'
self.CONF.set_override("rest_notifier_ssl_verify", False, self.CONF.set_override("rest_notifier_ssl_verify", False)
group='alarm')
with mock.patch('eventlet.spawn_n', self._fake_spawn_n): with mock.patch('eventlet.spawn_n', self._fake_spawn_n):
with mock.patch.object(requests.Session, 'post') as poster: with mock.patch.object(requests.Session, 'post') as poster:

View File

@ -263,7 +263,7 @@ function start_aodh {
fi fi
fi fi
run_process aodh-alarm-notifier "$AODH_BIN_DIR/aodh-alarm-notifier --config-file $AODH_CONF" run_process aodh-notifier "$AODH_BIN_DIR/aodh-notifier --config-file $AODH_CONF"
run_process aodh-alarm-evaluator "$AODH_BIN_DIR/aodh-alarm-evaluator --config-file $AODH_CONF" run_process aodh-alarm-evaluator "$AODH_BIN_DIR/aodh-alarm-evaluator --config-file $AODH_CONF"
} }
@ -274,7 +274,7 @@ function stop_aodh {
restart_apache_server restart_apache_server
fi fi
# Kill the aodh screen windows # Kill the aodh screen windows
for serv in aodh-api aodh-alarm-notifier aodh-alarm-evaluator; do for serv in aodh-api aodh-notifier aodh-alarm-evaluator; do
stop_process $serv stop_process $serv
done done
} }

View File

@ -2,7 +2,7 @@
# API service # API service
enable_service aodh-api enable_service aodh-api
# Alarming # Alarming
enable_service aodh-alarm-notifier aodh-alarm-evaluator enable_service aodh-notifier aodh-alarm-evaluator
# Ensure legacy ceilometer alarm stuffs is disabled # Ensure legacy ceilometer alarm stuffs is disabled
disable_service ceilometer-alarm-notifier ceilometer-alarm-evaluator disable_service ceilometer-alarm-notifier ceilometer-alarm-evaluator

View File

@ -45,7 +45,7 @@ Configuring devstack
[[local|localrc]] [[local|localrc]]
# Enable the aodh alarming services # Enable the aodh alarming services
enable_service aodh-alarm-evaluator,aodh-alarm-notifier enable_service aodh-alarm-evaluator,aodh-notifier
The first group of daemons are necessary for core aodh functionality: The first group of daemons are necessary for core aodh functionality:
polling, event listening, and data collection. polling, event listening, and data collection.

View File

@ -49,20 +49,20 @@ aodh.alarm.evaluator =
gnocchi_aggregation_by_metrics_threshold = aodh.alarm.evaluator.gnocchi:GnocchiThresholdEvaluator gnocchi_aggregation_by_metrics_threshold = aodh.alarm.evaluator.gnocchi:GnocchiThresholdEvaluator
gnocchi_aggregation_by_resources_threshold = aodh.alarm.evaluator.gnocchi:GnocchiThresholdEvaluator gnocchi_aggregation_by_resources_threshold = aodh.alarm.evaluator.gnocchi:GnocchiThresholdEvaluator
aodh.alarm.notifier = aodh.notifier =
log = aodh.alarm.notifier.log:LogAlarmNotifier log = aodh.notifier.log:LogAlarmNotifier
test = aodh.alarm.notifier.test:TestAlarmNotifier test = aodh.notifier.test:TestAlarmNotifier
http = aodh.alarm.notifier.rest:RestAlarmNotifier http = aodh.notifier.rest:RestAlarmNotifier
https = aodh.alarm.notifier.rest:RestAlarmNotifier https = aodh.notifier.rest:RestAlarmNotifier
trust+http = aodh.alarm.notifier.trust:TrustRestAlarmNotifier trust+http = aodh.notifier.trust:TrustRestAlarmNotifier
trust+https = aodh.alarm.notifier.trust:TrustRestAlarmNotifier trust+https = aodh.notifier.trust:TrustRestAlarmNotifier
console_scripts = console_scripts =
aodh-api = aodh.cmd.api:main aodh-api = aodh.cmd.api:main
aodh-dbsync = aodh.cmd.eventlet.storage:dbsync aodh-dbsync = aodh.cmd.eventlet.storage:dbsync
aodh-expirer = aodh.cmd.eventlet.storage:expirer aodh-expirer = aodh.cmd.eventlet.storage:expirer
aodh-alarm-evaluator = aodh.cmd.eventlet.alarm:evaluator aodh-alarm-evaluator = aodh.cmd.eventlet.alarm:evaluator
aodh-alarm-notifier = aodh.cmd.eventlet.alarm:notifier aodh-notifier = aodh.cmd.eventlet.alarm:notifier
oslo.config.opts = oslo.config.opts =
aodh = aodh.opts:list_opts aodh = aodh.opts:list_opts