diff --git a/heat/engine/resource.py b/heat/engine/resource.py index 9e8fdad9c..d65f67dad 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -884,10 +884,6 @@ class Resource(object): return 'Unknown' try: - if self.action in (self.SUSPEND, self.DELETE): - msg = _('Cannot signal resource during %s') % self.action - raise Exception(msg) - if not callable(getattr(self, 'handle_signal', None)): msg = (_('Resource %s is not able to receive a signal') % str(self)) diff --git a/heat/engine/resources/autoscaling.py b/heat/engine/resources/autoscaling.py index ab08aac81..e29a76ba8 100644 --- a/heat/engine/resources/autoscaling.py +++ b/heat/engine/resources/autoscaling.py @@ -948,6 +948,10 @@ class ScalingPolicy(signal_responder.SignalResponder, CooldownMixin): return self.properties[self.ADJUSTMENT_TYPE] def handle_signal(self, details=None): + if self.action in (self.SUSPEND, self.DELETE): + msg = _('Cannot signal resource during %s') % self.action + raise Exception(msg) + # ceilometer sends details like this: # {u'alarm_id': ID, u'previous': u'ok', u'current': u'alarm', # u'reason': u'...'}) diff --git a/heat/engine/resources/instance.py b/heat/engine/resources/instance.py index 4d627c097..c43de4119 100644 --- a/heat/engine/resources/instance.py +++ b/heat/engine/resources/instance.py @@ -66,6 +66,10 @@ class Restarter(signal_responder.SignalResponder): self.resource_id_set(self._get_user_id()) def handle_signal(self, details=None): + if self.action in (self.SUSPEND, self.DELETE): + msg = _('Cannot signal resource during %s') % self.action + raise Exception(msg) + if details is None: alarm_state = 'alarm' else: diff --git a/heat/tests/generic_resource.py b/heat/tests/generic_resource.py index 84ab7721e..78acf1f2b 100644 --- a/heat/tests/generic_resource.py +++ b/heat/tests/generic_resource.py @@ -112,6 +112,10 @@ class SignalResource(signal_responder.SignalResponder): self.resource_id_set(self._get_user_id()) def handle_signal(self, details=None): + if self.action in (self.SUSPEND, self.DELETE): + msg = _('Cannot signal resource during %s') % self.action + raise Exception(msg) + logger.warning(_('Signaled resource (Type "%(type)s") %(details)s') % {'type': self.type(), 'details': details})