From 8b0f80469b1b3dfc5fa30c43db983e4cc8a40ccd Mon Sep 17 00:00:00 2001 From: liusheng Date: Mon, 21 Dec 2015 15:52:18 +0800 Subject: [PATCH] Don't need a metaclass for AlarmEvaluationService We only have one subclass of evaluation service. Change-Id: I4f2dcdb2d426b9fb4fd07760bfc6e4f8116ccfbd --- aodh/evaluator/__init__.py | 24 ++++++------------------ aodh/tests/unit/test_evaluator.py | 2 +- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/aodh/evaluator/__init__.py b/aodh/evaluator/__init__.py index 220da9f21..9d1bb1e50 100644 --- a/aodh/evaluator/__init__.py +++ b/aodh/evaluator/__init__.py @@ -179,15 +179,18 @@ class Evaluator(object): """ -@six.add_metaclass(abc.ABCMeta) -class AlarmService(object): +class AlarmEvaluationService(os_service.Service): + + PARTITIONING_GROUP_NAME = "alarm_evaluator" EVALUATOR_EXTENSIONS_NAMESPACE = "aodh.evaluator" def __init__(self, conf): - super(AlarmService, self).__init__() + super(AlarmEvaluationService, self).__init__() self.conf = conf self.storage_conn = None self._load_evaluators() + self.partition_coordinator = coordination.PartitionCoordinator( + conf.coordination.backend_url) @property def _storage_conn(self): @@ -224,23 +227,8 @@ class AlarmService(object): except Exception: LOG.exception(_('Failed to evaluate alarm %s'), alarm.alarm_id) - @abc.abstractmethod - def _assigned_alarms(self): - pass - - -class AlarmEvaluationService(AlarmService, os_service.Service): - - PARTITIONING_GROUP_NAME = "alarm_evaluator" - - def __init__(self, conf): - super(AlarmEvaluationService, self).__init__(conf) - self.partition_coordinator = coordination.PartitionCoordinator( - conf.coordination.backend_url) - def start(self): super(AlarmEvaluationService, self).start() - self.storage_conn = storage.get_connection_from_config(self.conf) self.partition_coordinator.start() self.partition_coordinator.join_group(self.PARTITIONING_GROUP_NAME) diff --git a/aodh/tests/unit/test_evaluator.py b/aodh/tests/unit/test_evaluator.py index 3a8a3d84c..36b6fc70f 100644 --- a/aodh/tests/unit/test_evaluator.py +++ b/aodh/tests/unit/test_evaluator.py @@ -12,7 +12,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -"""Tests for aodh.service.SingletonAlarmService. +"""Tests for aodh.evaluator.AlarmEvaluationService. """ import mock from oslo_config import fixture as fixture_config