Fix StackResourceUnavailable exception
make this inherit from HeatException directly, report resource type instead of resouce name and expose it as HTTPBadRequest. Co-Authored-By: Kanagaraj Manickam <kanagaraj.manickam@hp.com> Change-Id: Iba33b0bb1cebfd66b8b721adcb24aa7b9a0beb5a
This commit is contained in:
parent
eb02839979
commit
7867dd6b9d
|
@ -91,6 +91,7 @@ class FaultWrapper(wsgi.Middleware):
|
|||
'IncompatibleObjectVersion': webob.exc.HTTPBadRequest,
|
||||
'OrphanedObjectError': webob.exc.HTTPBadRequest,
|
||||
'UnsupportedObjectError': webob.exc.HTTPBadRequest,
|
||||
'ResourceTypeUnavailable': webob.exc.HTTPBadRequest,
|
||||
}
|
||||
|
||||
def _map_exception_to_error(self, class_exception):
|
||||
|
|
|
@ -524,12 +524,6 @@ class SIGHUPInterrupt(HeatException):
|
|||
msg_fmt = _("System SIGHUP signal received.")
|
||||
|
||||
|
||||
class StackResourceUnavailable(StackValidationFailed):
|
||||
message = _("Service %(service_name)s does not have required endpoint in "
|
||||
"service catalog for the resource %(resource_name)s")
|
||||
|
||||
def __init__(self, service_name, resource_name):
|
||||
super(StackResourceUnavailable, self).__init__(
|
||||
message=self.message % dict(
|
||||
service_name=service_name,
|
||||
resource_name=resource_name))
|
||||
class ResourceTypeUnavailable(HeatException):
|
||||
msg_fmt = _("Service %(service_name)s does not have required endpoint in "
|
||||
"service catalog for the resource type %(resource_type)s")
|
||||
|
|
|
@ -168,9 +168,9 @@ class Resource(object):
|
|||
assert issubclass(ResourceClass, Resource)
|
||||
|
||||
if not ResourceClass.is_service_available(stack.context):
|
||||
ex = exception.StackResourceUnavailable(
|
||||
ex = exception.ResourceTypeUnavailable(
|
||||
service_name=ResourceClass.default_client_name,
|
||||
resource_name=name
|
||||
resource_type=definition.resource_type
|
||||
)
|
||||
LOG.error(six.text_type(ex))
|
||||
|
||||
|
|
|
@ -2399,7 +2399,7 @@ class ResourceAvailabilityTest(common.HeatTestCase):
|
|||
def test_service_not_deployed_throws_exception(self):
|
||||
'''
|
||||
When the service is not deployed, make sure resource is throwing
|
||||
StackResourceUnavailable exception.
|
||||
ResourceTypeUnavailable exception.
|
||||
'''
|
||||
with mock.patch.object(
|
||||
generic_rsrc.ResourceWithDefaultClientName,
|
||||
|
@ -2408,12 +2408,12 @@ class ResourceAvailabilityTest(common.HeatTestCase):
|
|||
|
||||
definition = rsrc_defn.ResourceDefinition(
|
||||
name='Test Resource',
|
||||
resource_type=mock.Mock())
|
||||
resource_type='UnavailableResourceType')
|
||||
|
||||
mock_stack = mock.MagicMock()
|
||||
|
||||
ex = self.assertRaises(
|
||||
exception.StackResourceUnavailable,
|
||||
exception.ResourceTypeUnavailable,
|
||||
generic_rsrc.ResourceWithDefaultClientName.__new__,
|
||||
cls=generic_rsrc.ResourceWithDefaultClientName,
|
||||
name='test_stack',
|
||||
|
@ -2421,7 +2421,7 @@ class ResourceAvailabilityTest(common.HeatTestCase):
|
|||
stack=mock_stack)
|
||||
|
||||
msg = ('Service sample does not have required endpoint in service'
|
||||
' catalog for the resource test_stack')
|
||||
' catalog for the resource type UnavailableResourceType')
|
||||
self.assertEqual(msg,
|
||||
six.text_type(ex),
|
||||
'invalid exception message')
|
||||
|
|
Loading…
Reference in New Issue