summaryrefslogtreecommitdiff
path: root/ceilometer/api/controllers/v2.py
diff options
context:
space:
mode:
Diffstat (limited to 'ceilometer/api/controllers/v2.py')
-rw-r--r--ceilometer/api/controllers/v2.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/ceilometer/api/controllers/v2.py b/ceilometer/api/controllers/v2.py
index a0abc98c..da712866 100644
--- a/ceilometer/api/controllers/v2.py
+++ b/ceilometer/api/controllers/v2.py
@@ -1082,7 +1082,7 @@ class AlarmThresholdRule(_Base):
#note(sileht): wsme mandatory doesn't work as expected
#workaround for https://bugs.launchpad.net/wsme/+bug/1227004
for field in ['meter_name', 'threshold']:
- if not getattr(threshold_rule, field):
+ if getattr(threshold_rule, field) in (wsme.Unset, None):
error = _("threshold_rule/%s is mandatory") % field
pecan.response.translatable_error = error
raise wsme.exc.ClientSideError(unicode(error))
@@ -1425,6 +1425,15 @@ class AlarmController(rest.RestController):
#https://bugs.launchpad.net/wsme/+bug/1220678
Alarm.validate(data)
+ # should check if there is any circle in the dependency, but for
+ # efficiency reason, here only check alarm cannot depend on itself
+ if data.type == 'combination':
+ if self._id in data.combination_rule.alarm_ids:
+ error = _('Cannot specify alarm %s itself in '
+ 'combination rule') % self._id
+ pecan.response.translatable_error = error
+ raise wsme.exc.ClientSideError(unicode(error))
+
old_alarm = Alarm.from_db_model(alarm_in).as_dict(storage.models.Alarm)
updated_alarm = data.as_dict(storage.models.Alarm)
try: