Merge "Add loadbalancer_member_health type alarm rule"

This commit is contained in:
Zuul 2019-04-22 07:40:05 +00:00 committed by Gerrit Code Review
commit 855e31283e
3 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,39 @@
# Copyright 2019 Catalyst Cloud Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import wsme
from wsme import types as wtypes
from aodh.api.controllers.v2 import base
class LoadBalancerMemberHealthRule(base.AlarmRule):
pool_id = wsme.wsattr(wtypes.text, mandatory=True)
"ID of a load balancer pool the members belongs to."
stack_id = wsme.wsattr(wtypes.text, mandatory=True)
"ID of a Heat stack which contains the load balancer member."
autoscaling_group_id = wsme.wsattr(wtypes.text, mandatory=True)
"ID of a Heat autoscaling group that contains the load balancer member."
def as_dict(self):
rule = self.as_dict_from_keys(
['pool_id', 'stack_id', 'autoscaling_group_id']
)
return rule
@staticmethod
def create_hook(alarm):
pass

View File

@ -2401,6 +2401,26 @@ class TestAlarmsRuleGnocchi(TestAlarmsBase):
self._verify_alarm(json, alarms[0])
class TestAlarmsRuleLoadBalancer(TestAlarmsBase):
def test_post(self):
json = {
'name': 'added_alarm_defaults',
'type': 'loadbalancer_member_health',
'loadbalancer_member_health_rule': {
"pool_id": "2177ccd8-b09c-417a-89a0-e8d2419be612",
"stack_id": "1b974012-ebcb-4888-8ae2-47714d4d2c4d",
"autoscaling_group_id": "681c9266-61d2-4c9a-ad18-526807f6adc0"
}
}
self.post_json('/alarms', params=json, status=201,
headers=self.auth_headers)
alarms = list(self.alarm_conn.get_alarms())
self.assertEqual(1, len(alarms))
self._verify_alarm(json, alarms[0])
class TestAlarmsEvent(TestAlarmsBase):
def test_list_alarms(self):

View File

@ -73,6 +73,7 @@ aodh.alarm.rule =
gnocchi_aggregation_by_resources_threshold = aodh.api.controllers.v2.alarm_rules.gnocchi:AggregationMetricByResourcesLookupRule
event = aodh.api.controllers.v2.alarm_rules.event:AlarmEventRule
composite = aodh.api.controllers.v2.alarm_rules.composite:composite_rule
loadbalancer_member_health = aodh.api.controllers.v2.alarm_rules.loadbalancer:LoadBalancerMemberHealthRule
aodh.evaluator =
gnocchi_resources_threshold = aodh.evaluator.gnocchi:GnocchiResourceThresholdEvaluator