Merge "Allow handle_signal to assert which actions are valid"
This commit is contained in:
commit
c186fa7d28
@ -884,10 +884,6 @@ class Resource(object):
|
|||||||
return 'Unknown'
|
return 'Unknown'
|
||||||
|
|
||||||
try:
|
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)):
|
if not callable(getattr(self, 'handle_signal', None)):
|
||||||
msg = (_('Resource %s is not able to receive a signal') %
|
msg = (_('Resource %s is not able to receive a signal') %
|
||||||
str(self))
|
str(self))
|
||||||
|
@ -948,6 +948,10 @@ class ScalingPolicy(signal_responder.SignalResponder, CooldownMixin):
|
|||||||
return self.properties[self.ADJUSTMENT_TYPE]
|
return self.properties[self.ADJUSTMENT_TYPE]
|
||||||
|
|
||||||
def handle_signal(self, details=None):
|
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:
|
# ceilometer sends details like this:
|
||||||
# {u'alarm_id': ID, u'previous': u'ok', u'current': u'alarm',
|
# {u'alarm_id': ID, u'previous': u'ok', u'current': u'alarm',
|
||||||
# u'reason': u'...'})
|
# u'reason': u'...'})
|
||||||
|
@ -66,6 +66,10 @@ class Restarter(signal_responder.SignalResponder):
|
|||||||
self.resource_id_set(self._get_user_id())
|
self.resource_id_set(self._get_user_id())
|
||||||
|
|
||||||
def handle_signal(self, details=None):
|
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:
|
if details is None:
|
||||||
alarm_state = 'alarm'
|
alarm_state = 'alarm'
|
||||||
else:
|
else:
|
||||||
|
@ -112,6 +112,10 @@ class SignalResource(signal_responder.SignalResponder):
|
|||||||
self.resource_id_set(self._get_user_id())
|
self.resource_id_set(self._get_user_id())
|
||||||
|
|
||||||
def handle_signal(self, details=None):
|
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')
|
logger.warning(_('Signaled resource (Type "%(type)s") %(details)s')
|
||||||
% {'type': self.type(), 'details': details})
|
% {'type': self.type(), 'details': details})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user