Appropriate exception for signal handling failure
Raise an appropriate exception, mapped to a 400 error for signals to resources which cannot handle signals. In this case, the request is inherently impossible to satisfy, because the plugin doesn't support signals, so we should alert the user to this by saying it's a bad request (rather than the current response which is a 500 error) Change-Id: I8e47ee94e15309f378f62f2a9f6534a4eeddb389 Closes-Bug: #1346849
This commit is contained in:
parent
22095896d6
commit
0909340b4c
|
@ -270,6 +270,7 @@ def map_remote_error(ex):
|
|||
'ValueError',
|
||||
'InvalidTenant',
|
||||
'StackNotFound',
|
||||
'ResourceActionNotSupported',
|
||||
'ResourceNotFound',
|
||||
'ResourceNotAvailable',
|
||||
'ResourceTypeNotFound',
|
||||
|
|
|
@ -60,6 +60,7 @@ class FaultWrapper(wsgi.Middleware):
|
|||
'ValueError': webob.exc.HTTPBadRequest,
|
||||
'StackNotFound': webob.exc.HTTPNotFound,
|
||||
'NotFound': webob.exc.HTTPNotFound,
|
||||
'ResourceActionNotSupported': webob.exc.HTTPBadRequest,
|
||||
'ResourceNotFound': webob.exc.HTTPNotFound,
|
||||
'ResourceTypeNotFound': webob.exc.HTTPNotFound,
|
||||
'ResourceNotAvailable': webob.exc.HTTPNotFound,
|
||||
|
|
|
@ -296,6 +296,10 @@ class NotSupported(HeatException):
|
|||
msg_fmt = _("%(feature)s is not supported.")
|
||||
|
||||
|
||||
class ResourceActionNotSupported(HeatException):
|
||||
msg_fmt = _("%(action)s is not supported for resource.")
|
||||
|
||||
|
||||
class ResourcePropertyConflict(HeatException):
|
||||
msg_fmt = _('Cannot define the following properties at the same time: %s.')
|
||||
|
||||
|
|
|
@ -934,13 +934,10 @@ class Resource(object):
|
|||
'(%(deploy_status_code)s)' % details)
|
||||
|
||||
return 'Unknown'
|
||||
if not callable(getattr(self, 'handle_signal', None)):
|
||||
raise exception.ResourceActionNotSupported(action='signal')
|
||||
|
||||
try:
|
||||
if not callable(getattr(self, 'handle_signal', None)):
|
||||
msg = (_('Resource %s is not able to receive a signal') %
|
||||
str(self))
|
||||
raise Exception(msg)
|
||||
|
||||
signal_result = self.handle_signal(details)
|
||||
if signal_result:
|
||||
reason_string = "Signal: %s" % signal_result
|
||||
|
|
|
@ -333,7 +333,7 @@ class SignalTest(HeatTestCase):
|
|||
self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
|
||||
|
||||
err_metadata = {'Data': 'foo', 'Status': 'SUCCESS', 'UniqueId': '123'}
|
||||
self.assertRaises(exception.ResourceFailure, rsrc.signal,
|
||||
self.assertRaises(exception.ResourceActionNotSupported, rsrc.signal,
|
||||
details=err_metadata)
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
|
Loading…
Reference in New Issue