From 3c8e02911670e1943c756893ee6c0bf13fd4528b Mon Sep 17 00:00:00 2001 From: Alexey Weyl Date: Tue, 10 Jan 2017 14:45:36 +0000 Subject: [PATCH] property refactoring Change-Id: Ie5680f08e7715c0f2d0b02fa67b58cf3234f79fc --- aodh/evaluator/__init__.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/aodh/evaluator/__init__.py b/aodh/evaluator/__init__.py index 877c93e89..2505da63e 100644 --- a/aodh/evaluator/__init__.py +++ b/aodh/evaluator/__init__.py @@ -78,6 +78,14 @@ class Evaluator(object): self.storage_conn = storage.get_connection_from_config(self.conf) return self.storage_conn + @property + def alarm_change_notifier(self): + if not self._alarm_change_notifier: + transport = messaging.get_transport(self.conf) + self._alarm_change_notifier = messaging.get_notifier( + transport, publisher_id="aodh.evaluator") + return self._alarm_change_notifier + def _record_change(self, alarm, reason): if not self.conf.record_history: return @@ -100,13 +108,9 @@ class Evaluator(object): self._storage_conn.record_alarm_change(payload) except aodh.NotImplementedError: pass - if not self._alarm_change_notifier: - transport = messaging.get_transport(self.conf) - self._alarm_change_notifier = messaging.get_notifier( - transport, publisher_id="aodh.evaluator") notification = "alarm.state_transition" - self._alarm_change_notifier.info({}, - notification, payload) + self.alarm_change_notifier.info({}, + notification, payload) def _refresh(self, alarm, state, reason, reason_data, always_record=False): """Refresh alarm state."""