Merge "change alarms to use UpdateAllowed property schema"

This commit is contained in:
Jenkins
2013-10-25 12:07:48 +00:00
committed by Gerrit Code Review
3 changed files with 35 additions and 27 deletions
+11 -8
View File
@@ -24,6 +24,7 @@ class CeilometerAlarm(resource.Resource):
'comparison_operator': {
'Type': 'String',
'Required': True,
'UpdateAllowed': True,
'AllowedValues': ['ge', 'gt', 'eq', 'ne', 'lt', 'le'],
'Description': _('Operator used to compare specified statistic '
'with threshold.')
@@ -31,6 +32,7 @@ class CeilometerAlarm(resource.Resource):
'evaluation_periods': {
'Type': 'String',
'Required': True,
'UpdateAllowed': True,
'Description': _('Number of periods to evaluate over.')
},
'meter_name': {
@@ -41,46 +43,55 @@ class CeilometerAlarm(resource.Resource):
'period': {
'Type': 'String',
'Required': True,
'UpdateAllowed': True,
'Description': _('Period (seconds) to evaluate over.')
},
'statistic': {
'Type': 'String',
'Required': True,
'UpdateAllowed': True,
'AllowedValues': ['count', 'avg', 'sum', 'min', 'max'],
'Description': _('Meter statistic to evaluate.')
},
'threshold': {
'Type': 'String',
'Required': True,
'UpdateAllowed': True,
'Description': _('Threshold to evaluate against.')
},
'alarm_actions': {
'Type': 'List',
'UpdateAllowed': True,
'Description': _('A list of URLs (webhooks) to invoke when state '
'transitions to alarm.')
},
'ok_actions': {
'Type': 'List',
'UpdateAllowed': True,
'Description': _('A list of URLs (webhooks) to invoke when state '
'transitions to ok.')
},
'insufficient_data_actions': {
'Type': 'List',
'UpdateAllowed': True,
'Description': _('A list of URLs (webhooks) to invoke when state '
'transitions to insufficient-data.')
},
'description': {
'Type': 'String',
'UpdateAllowed': True,
'Description': _('Description for the alarm.')
},
'enabled': {
'Type': 'Boolean',
'UpdateAllowed': True,
'Default': 'true',
'Description': _('True if alarm evaluation/actioning is enabled.')
},
'repeat_actions': {
'Type': 'Boolean',
'Default': 'true',
'UpdateAllowed': True,
'Description': _('False to trigger actions when the threshold is '
'reached AND the alarm\'s state has changed. '
'By default, actions are called each time '
@@ -94,14 +105,6 @@ class CeilometerAlarm(resource.Resource):
}
update_allowed_keys = ('Properties',)
# allow the properties that affect the watch calculation.
# note: when using in-instance monitoring you can only change the
# metric name if you re-configure the instance too.
update_allowed_properties = ('comparison_operator', 'description',
'evaluation_periods', 'period', 'statistic',
'alarm_actions', 'ok_actions',
'insufficient_data_actions', 'threshold',
'enabled', 'repeat_actions')
def _actions_to_urls(self, props):
kwargs = {}
+20 -17
View File
@@ -32,15 +32,18 @@ class CloudWatchAlarm(resource.Resource):
'LessThanThreshold',
'LessThanOrEqualToThreshold'],
'Description': _('Operator used to compare the specified '
'Statistic with Threshold.')
'Statistic with Threshold.'),
'UpdateAllowed': True,
},
'AlarmDescription': {
'Type': 'String',
'Description': _('Description for the alarm.')
'Description': _('Description for the alarm.'),
'UpdateAllowed': True,
},
'EvaluationPeriods': {
'Type': 'String',
'Description': _('Number of periods to evaluate over.')
'Description': _('Number of periods to evaluate over.'),
'UpdateAllowed': True,
},
'MetricName': {
'Type': 'String',
@@ -52,7 +55,8 @@ class CloudWatchAlarm(resource.Resource):
},
'Period': {
'Type': 'String',
'Description': _('Period (seconds) to evaluate over.')
'Description': _('Period (seconds) to evaluate over.'),
'UpdateAllowed': True,
},
'Statistic': {
'Type': 'String',
@@ -61,17 +65,20 @@ class CloudWatchAlarm(resource.Resource):
'Sum',
'Minimum',
'Maximum'],
'Description': _('Metric statistic to evaluate.')
'Description': _('Metric statistic to evaluate.'),
'UpdateAllowed': True,
},
'AlarmActions': {
'Type': 'List',
'Description': _('A list of actions to execute when state '
'transitions to alarm.')
'transitions to alarm.'),
'UpdateAllowed': True,
},
'OKActions': {
'Type': 'List',
'Description': _('A list of actions to execute when state '
'transitions to ok.')
'transitions to ok.'),
'UpdateAllowed': True,
},
'Dimensions': {
'Type': 'List',
@@ -81,11 +88,13 @@ class CloudWatchAlarm(resource.Resource):
'InsufficientDataActions': {
'Type': 'List',
'Description': _('A list of actions to execute when state '
'transitions to insufficient-data.')
'transitions to insufficient-data.'),
'UpdateAllowed': True,
},
'Threshold': {
'Type': 'String',
'Description': _('Threshold to evaluate against.')
'Description': _('Threshold to evaluate against.'),
'UpdateAllowed': True,
},
'Units': {
'Type': 'String',
@@ -116,19 +125,13 @@ class CloudWatchAlarm(resource.Resource):
'Terabits/Second',
'Count/Second',
None],
'Description': _('Unit for the metric.')
'Description': _('Unit for the metric.'),
'UpdateAllowed': True,
}
}
strict_dependency = False
update_allowed_keys = ('Properties',)
# allow the properties that affect the watch calculation.
# note: when using in-instance monitoring you can only change the
# metric name if you re-configure the instance too.
update_allowed_properties = ('ComparisonOperator', 'AlarmDescription',
'EvaluationPeriods', 'Period', 'Statistic',
'AlarmActions', 'OKActions', 'Units'
'InsufficientDataActions', 'Threshold')
def handle_create(self):
wr = watchrule.WatchRule(context=self.context,
+4 -2
View File
@@ -142,8 +142,10 @@ class CeilometerAlarmTest(HeatTestCase):
self.stack = self.create_stack(template=json.dumps(t))
self.m.StubOutWithMock(self.fa.alarms, 'update')
al2 = {}
for k in alarm.CeilometerAlarm.update_allowed_properties:
al2[k] = mox.IgnoreArg()
for k in alarm.CeilometerAlarm.properties_schema:
if alarm.CeilometerAlarm.properties_schema[k].get('UpdateAllowed',
False):
al2[k] = mox.IgnoreArg()
al2['alarm_id'] = mox.IgnoreArg()
self.fa.alarms.update(**al2).AndReturn(None)