]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Tolerance for modified ceilometer alarm notification
authorEoghan Glynn <eglynn@redhat.com>
Fri, 9 Aug 2013 09:42:53 +0000 (09:42 +0000)
committerEoghan Glynn <eglynn@redhat.com>
Fri, 9 Aug 2013 11:04:20 +0000 (12:04 +0100)
Changes to the ceilometer alarm notification payload are
proposed here:

  https://review.openstack.org/40955
  https://review.openstack.org/41056

i.e. field names in the JSON payload are changed with:

  s/state/current/
  s/alarm/alarm_id/

Tolerance is added to the autoscaling logic for the new
field names.

Change-Id: I19f36d9331b6f28a3195fb5012ea0b9ee274ade3

heat/engine/resources/autoscaling.py

index 54b15e05087b05dc43f7aaeac4d730e17caba244..270d27bd5120e1d26da7c88eef9b88a976388ee3 100644 (file)
@@ -396,7 +396,8 @@ class ScalingPolicy(signal_responder.SignalResponder, CooldownMixin):
 
     def handle_signal(self, details=None):
         # ceilometer sends details like this:
-        # {u'state': u'alarm', u'reason': u'...'})
+        # {u'alarm_id': ID, u'previous': u'ok', u'current': u'alarm',
+        #  u'reason': u'...'})
         # in this policy we currently assume that this gets called
         # only when there is an alarm. But the template writer can
         # put the policy in all the alarm notifiers (nodata, and ok).
@@ -405,7 +406,8 @@ class ScalingPolicy(signal_responder.SignalResponder, CooldownMixin):
         if details is None:
             alarm_state = 'alarm'
         else:
-            alarm_state = details.get('state', 'alarm').lower()
+            alarm_state = details.get('current',
+                                      details.get('state', 'alarm')).lower()
 
         logger.info('%s Alarm, new state %s' % (self.name, alarm_state))