From f44e292e7a16d09db36d8b2f9223e3d54202f8d2 Mon Sep 17 00:00:00 2001 From: Eoghan Glynn Date: Wed, 9 Oct 2013 19:57:10 +0100 Subject: [PATCH] Ensure combination alarms can be evaluated Fixes bug 1237589 Previously the retrieval of state for the constituent alarms always failed for combination alarms, due to an incorrect attribute of ceilometerclient being used. As a result combination alarms could never be successfully evaluated. Now the correct pluralized attribute is used. Change-Id: Id58a5d185854367e5a08011048774ab5aed93d4e --- ceilometer/alarm/evaluator/combination.py | 2 +- tests/alarm/evaluator/test_combination.py | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ceilometer/alarm/evaluator/combination.py b/ceilometer/alarm/evaluator/combination.py index 5ee3c52c2..82948eb24 100644 --- a/ceilometer/alarm/evaluator/combination.py +++ b/ceilometer/alarm/evaluator/combination.py @@ -31,7 +31,7 @@ class CombinationEvaluator(evaluator.Evaluator): def _get_alarm_state(self, alarm_id): try: - alarm = self._client.alarm.get(alarm_id) + alarm = self._client.alarms.get(alarm_id) except Exception: LOG.exception(_('alarm retrieval failed')) return None diff --git a/tests/alarm/evaluator/test_combination.py b/tests/alarm/evaluator/test_combination.py index eeb7d7342..633266a9a 100644 --- a/tests/alarm/evaluator/test_combination.py +++ b/tests/alarm/evaluator/test_combination.py @@ -103,7 +103,7 @@ class TestEvaluate(base.TestEvaluatorBase): with mock.patch('ceilometerclient.client.get_client', return_value=self.api_client): broken = exc.CommunicationError(message='broken') - self.api_client.alarm.get.side_effect = [ + self.api_client.alarms.get.side_effect = [ broken, broken, broken, @@ -123,7 +123,7 @@ class TestEvaluate(base.TestEvaluatorBase): with mock.patch('ceilometerclient.client.get_client', return_value=self.api_client): broken = exc.CommunicationError(message='broken') - self.api_client.alarm.get.side_effect = broken + self.api_client.alarms.get.side_effect = broken self._evaluate_all_alarms() self._assert_all_alarms('insufficient data') expected = [mock.call(alarm.alarm_id, state='insufficient data') @@ -141,7 +141,7 @@ class TestEvaluate(base.TestEvaluatorBase): self._set_all_alarms('insufficient data') with mock.patch('ceilometerclient.client.get_client', return_value=self.api_client): - self.api_client.alarm.get.side_effect = [ + self.api_client.alarms.get.side_effect = [ self._get_alarm('ok'), self._get_alarm('ok'), self._get_alarm('ok'), @@ -161,7 +161,7 @@ class TestEvaluate(base.TestEvaluatorBase): self._set_all_alarms('alarm') with mock.patch('ceilometerclient.client.get_client', return_value=self.api_client): - self.api_client.alarm.get.side_effect = [ + self.api_client.alarms.get.side_effect = [ self._get_alarm('ok'), self._get_alarm('ok'), self._get_alarm('alarm'), @@ -181,7 +181,7 @@ class TestEvaluate(base.TestEvaluatorBase): self._set_all_alarms('ok') with mock.patch('ceilometerclient.client.get_client', return_value=self.api_client): - self.api_client.alarm.get.side_effect = [ + self.api_client.alarms.get.side_effect = [ self._get_alarm('alarm'), self._get_alarm('alarm'), self._get_alarm('alarm'), @@ -201,7 +201,7 @@ class TestEvaluate(base.TestEvaluatorBase): self._set_all_alarms('ok') with mock.patch('ceilometerclient.client.get_client', return_value=self.api_client): - self.api_client.alarm.get.side_effect = [ + self.api_client.alarms.get.side_effect = [ self._get_alarm('ok'), self._get_alarm('alarm'), self._get_alarm('alarm'), @@ -222,7 +222,7 @@ class TestEvaluate(base.TestEvaluatorBase): with mock.patch('ceilometerclient.client.get_client', return_value=self.api_client): broken = exc.CommunicationError(message='broken') - self.api_client.alarm.get.side_effect = [ + self.api_client.alarms.get.side_effect = [ broken, self._get_alarm('ok'), self._get_alarm('insufficient data'), @@ -249,7 +249,7 @@ class TestEvaluate(base.TestEvaluatorBase): self._set_all_alarms('ok') with mock.patch('ceilometerclient.client.get_client', return_value=self.api_client): - self.api_client.alarm.get.side_effect = [ + self.api_client.alarms.get.side_effect = [ self._get_alarm('ok'), self._get_alarm('ok'), self._get_alarm('ok'), @@ -266,7 +266,7 @@ class TestEvaluate(base.TestEvaluatorBase): self._set_all_alarms('ok') with mock.patch('ceilometerclient.client.get_client', return_value=self.api_client): - self.api_client.alarm.get.side_effect = [ + self.api_client.alarms.get.side_effect = [ self._get_alarm('ok'), self._get_alarm('ok'), self._get_alarm('ok'),