Exclude event type from targets of alarm evaluator

The new evaluator service will be added to handle 'event' type alarms
only. Existing evaluator have to exclude those 'event' type alarms
from their targets which will be evaluated periodically.

Change-Id: Ia501771ee8d3dcd424c7e415d8aeb3d41a8e8de0
Implements: blueprint event-alarm-evaluator
This commit is contained in:
Ryota MIBU 2015-08-07 12:38:56 +09:00
parent 18637b5c6b
commit 1cc7087af1
2 changed files with 15 additions and 1 deletions

View File

@ -259,6 +259,10 @@ class AlarmEvaluationService(AlarmService, os_service.Service):
self.tg.add_timer(604800, lambda: None) self.tg.add_timer(604800, lambda: None)
def _assigned_alarms(self): def _assigned_alarms(self):
all_alarms = self._storage_conn.get_alarms(enabled=True) # NOTE(r-mibu): The 'event' type alarms will be evaluated by the
# event-driven alarm evaluator, so this periodical evaluator skips
# those alarms.
all_alarms = self._storage_conn.get_alarms(enabled=True,
exclude=dict(type='event'))
return self.partition_coordinator.extract_my_subset( return self.partition_coordinator.extract_my_subset(
self.PARTITIONING_GROUP_NAME, all_alarms) self.PARTITIONING_GROUP_NAME, all_alarms)

View File

@ -135,3 +135,13 @@ class TestAlarmEvaluationService(tests_base.BaseTestCase):
self.svc.start() self.svc.start()
self.svc._evaluate_assigned_alarms() self.svc._evaluate_assigned_alarms()
self.threshold_eval.evaluate.assert_called_once_with(alarms[1]) self.threshold_eval.evaluate.assert_called_once_with(alarms[1])
def test_check_alarm_query_constraints(self):
self.storage_conn.get_alarms.return_value = []
with mock.patch('aodh.storage.get_connection_from_config',
return_value=self.storage_conn):
self.svc.start()
self.svc._evaluate_assigned_alarms()
expected = [({'enabled': True, 'exclude': {'type': 'event'}},)]
self.assertEqual(expected,
self.storage_conn.get_alarms.call_args_list)