From e01346dcc8e4e4986d7a475259b2e451a8fe45f6 Mon Sep 17 00:00:00 2001 From: Benjamin Diaz Date: Wed, 10 Oct 2018 12:26:50 -0300 Subject: [PATCH] Sets repeat_action to True in OpenStack alarm creation Alarms created in OpenStack will be configured to retrigger actions during each evaluation cycle if they are still in alarm state. Signed-off-by: Benjamin Diaz --- osm_mon/plugins/OpenStack/Aodh/alarming.py | 3 ++- osm_mon/test/OpenStack/unit/test_alarming.py | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/osm_mon/plugins/OpenStack/Aodh/alarming.py b/osm_mon/plugins/OpenStack/Aodh/alarming.py index 15751f2..b71700e 100644 --- a/osm_mon/plugins/OpenStack/Aodh/alarming.py +++ b/osm_mon/plugins/OpenStack/Aodh/alarming.py @@ -357,7 +357,8 @@ class Alarming(object): 'severity': SEVERITIES[severity], 'type': 'gnocchi_resources_threshold', 'gnocchi_resources_threshold_rule': rule, - 'alarm_actions': [cfg.OS_NOTIFIER_URI], }, sort_keys=True) + 'alarm_actions': [cfg.OS_NOTIFIER_URI], + 'repeat_actions': True}, sort_keys=True) return payload def get_alarm_state(self, endpoint, auth_token, alarm_id): diff --git a/osm_mon/test/OpenStack/unit/test_alarming.py b/osm_mon/test/OpenStack/unit/test_alarming.py index 8c3841a..7368f13 100644 --- a/osm_mon/test/OpenStack/unit/test_alarming.py +++ b/osm_mon/test/OpenStack/unit/test_alarming.py @@ -95,7 +95,7 @@ class TestAlarming(unittest.TestCase): "granularity": "300", "metric": "disk.write.requests", "aggregation_method": "mean", "threshold": 60, "resource_id": "my_r_id"}, - "alarm_actions": ["http://localhost:8662"], "state": "ok", "type": "gnocchi_resources_threshold", + "alarm_actions": ["http://localhost:8662"], "repeat_actions": True, "state": "ok", "type": "gnocchi_resources_threshold", "severity": "critical"} perf_req.assert_called_with( "alarm_endpoint/v2/alarms/", auth_token, @@ -235,7 +235,8 @@ class TestAlarming(unittest.TestCase): "severity": "low", "state": "ok", "type": "gnocchi_resources_threshold", - "alarm_actions": ["http://localhost:8662"]}) + "alarm_actions": ["http://localhost:8662"], + "repeat_actions": True}) @mock.patch.object(Config, "instance") @mock.patch.object(Common, "perform_request") @@ -264,7 +265,8 @@ class TestAlarming(unittest.TestCase): "severity": "low", "state": "alarm", "type": "gnocchi_resources_threshold", - "alarm_actions": ["http://localhost:8662"]}) + "alarm_actions": ["http://localhost:8662"], + "repeat_actions": True}) def test_check_invalid_payload(self): """Test the check payload function for an invalid payload.""" -- 2.17.1