Use EntityNotFound instead of ResourceTypeNotFound.
Replace and remove ResourceTypeNotFound. Change-Id: I1761eb59021b20625ea1886c5e70c8a0f9633d17 Partial-Bug: #1515603
This commit is contained in:
parent
417deb7730
commit
f3556594b7
|
@ -288,7 +288,6 @@ def map_remote_error(ex):
|
|||
'ResourceActionNotSupported',
|
||||
'ResourceNotFound',
|
||||
'ResourceNotAvailable',
|
||||
'ResourceTypeNotFound',
|
||||
'PhysicalResourceNotFound',
|
||||
'WatchRuleNotFound',
|
||||
'StackValidationFailed',
|
||||
|
|
|
@ -60,7 +60,6 @@ class FaultWrapper(wsgi.Middleware):
|
|||
'NotFound': webob.exc.HTTPNotFound,
|
||||
'ResourceActionNotSupported': webob.exc.HTTPBadRequest,
|
||||
'ResourceNotFound': webob.exc.HTTPNotFound,
|
||||
'ResourceTypeNotFound': webob.exc.HTTPNotFound,
|
||||
'SnapshotNotFound': webob.exc.HTTPNotFound,
|
||||
'ResourceNotAvailable': webob.exc.HTTPNotFound,
|
||||
'PhysicalResourceNotFound': webob.exc.HTTPNotFound,
|
||||
|
|
|
@ -213,10 +213,6 @@ class TemplateNotFound(HeatException):
|
|||
msg_fmt = _("%(message)s")
|
||||
|
||||
|
||||
class ResourceTypeNotFound(HeatException):
|
||||
msg_fmt = _("The Resource Type (%(type_name)s) could not be found.")
|
||||
|
||||
|
||||
class InvalidResourceType(HeatException):
|
||||
msg_fmt = _("%(message)s")
|
||||
|
||||
|
|
|
@ -431,7 +431,8 @@ class ResourceRegistry(object):
|
|||
info = self.get_resource_info(resource_type,
|
||||
resource_name=resource_name)
|
||||
if info is None:
|
||||
raise exception.ResourceTypeNotFound(type_name=resource_type)
|
||||
raise exception.EntityNotFound(entity='Resource Type',
|
||||
name=resource_type)
|
||||
return info.get_class(files=files)
|
||||
|
||||
def as_dict(self):
|
||||
|
|
|
@ -1221,7 +1221,7 @@ class EngineService(service.Service):
|
|||
try:
|
||||
resource_class = resources.global_env().get_class(type_name)
|
||||
except (exception.InvalidResourceType,
|
||||
exception.ResourceTypeNotFound,
|
||||
exception.EntityNotFound,
|
||||
exception.TemplateNotFound) as ex:
|
||||
raise ex
|
||||
|
||||
|
@ -1270,7 +1270,7 @@ class EngineService(service.Service):
|
|||
return resource_class.resource_to_template(type_name,
|
||||
template_type)
|
||||
except (exception.InvalidResourceType,
|
||||
exception.ResourceTypeNotFound,
|
||||
exception.EntityNotFound,
|
||||
exception.TemplateNotFound) as ex:
|
||||
raise ex
|
||||
|
||||
|
|
|
@ -2183,7 +2183,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
|
|||
self._mock_enforce_setup(mock_enforce, 'list_resource_types', True)
|
||||
req = self._get('/resource_types')
|
||||
|
||||
error = heat_exc.ResourceTypeNotFound(type_name='')
|
||||
error = heat_exc.EntityNotFound(entity='Resource Type', name='')
|
||||
self.m.StubOutWithMock(rpc_client.EngineClient, 'call')
|
||||
rpc_client.EngineClient.call(
|
||||
req.context,
|
||||
|
@ -2203,7 +2203,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
|
|||
req, tenant_id=self.tenant)
|
||||
|
||||
self.assertEqual(404, resp.json['code'])
|
||||
self.assertEqual('ResourceTypeNotFound', resp.json['error']['type'])
|
||||
self.assertEqual('EntityNotFound', resp.json['error']['type'])
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_list_resource_types_err_denied_policy(self, mock_enforce):
|
||||
|
@ -2293,7 +2293,8 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
|
|||
req = self._get('/resource_types/BogusResourceType')
|
||||
type_name = 'BogusResourceType'
|
||||
|
||||
error = heat_exc.ResourceTypeNotFound(type_name='BogusResourceType')
|
||||
error = heat_exc.EntityNotFound(entity='Resource Type',
|
||||
name='BogusResourceType')
|
||||
self.m.StubOutWithMock(rpc_client.EngineClient, 'call')
|
||||
rpc_client.EngineClient.call(
|
||||
req.context,
|
||||
|
@ -2306,7 +2307,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
|
|||
req, tenant_id=self.tenant,
|
||||
type_name=type_name)
|
||||
self.assertEqual(404, resp.json['code'])
|
||||
self.assertEqual('ResourceTypeNotFound', resp.json['error']['type'])
|
||||
self.assertEqual('EntityNotFound', resp.json['error']['type'])
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_resource_schema_err_denied_policy(self, mock_enforce):
|
||||
|
@ -2360,7 +2361,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
|
|||
self._mock_enforce_setup(mock_enforce, 'generate_template', True)
|
||||
req = self._get('/resource_types/NOT_FOUND/template')
|
||||
|
||||
error = heat_exc.ResourceTypeNotFound(type_name='a')
|
||||
error = heat_exc.EntityNotFound(entity='Resource Type', name='a')
|
||||
self.m.StubOutWithMock(rpc_client.EngineClient, 'call')
|
||||
rpc_client.EngineClient.call(
|
||||
req.context,
|
||||
|
@ -2374,7 +2375,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
|
|||
req, tenant_id=self.tenant,
|
||||
type_name='NOT_FOUND')
|
||||
self.assertEqual(404, resp.json['code'])
|
||||
self.assertEqual('ResourceTypeNotFound', resp.json['error']['type'])
|
||||
self.assertEqual('EntityNotFound', resp.json['error']['type'])
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_generate_template_err_denied_policy(self, mock_enforce):
|
||||
|
|
|
@ -148,7 +148,7 @@ class ResourceTypeTest(common.HeatTestCase):
|
|||
self._no_template_file(self.eng.generate_template)
|
||||
|
||||
def test_resource_schema_nonexist(self):
|
||||
ex = self.assertRaises(exception.ResourceTypeNotFound,
|
||||
ex = self.assertRaises(exception.EntityNotFound,
|
||||
self.eng.resource_schema,
|
||||
self.ctx, type_name='Bogus')
|
||||
msg = 'The Resource Type (Bogus) could not be found.'
|
||||
|
|
|
@ -73,7 +73,7 @@ class ResourceTest(common.HeatTestCase):
|
|||
self.assertEqual(generic_rsrc.GenericResource, cls)
|
||||
|
||||
def test_get_class_noexist(self):
|
||||
self.assertRaises(exception.ResourceTypeNotFound,
|
||||
self.assertRaises(exception.EntityNotFound,
|
||||
resources.global_env().get_class,
|
||||
'NoExistResourceType')
|
||||
|
||||
|
@ -173,7 +173,7 @@ class ResourceTest(common.HeatTestCase):
|
|||
def test_resource_new_err(self):
|
||||
snippet = rsrc_defn.ResourceDefinition('aresource',
|
||||
'NoExistResourceType')
|
||||
self.assertRaises(exception.ResourceTypeNotFound,
|
||||
self.assertRaises(exception.EntityNotFound,
|
||||
resource.Resource, 'aresource', snippet, self.stack)
|
||||
|
||||
def test_resource_non_type(self):
|
||||
|
|
|
@ -417,7 +417,7 @@ class ResourceGroupTest(common.HeatTestCase):
|
|||
stack = utils.parse_stack(tmp)
|
||||
snip = stack.t.resource_definitions(stack)['group1']
|
||||
resg = resource_group.ResourceGroup('test', snip, stack)
|
||||
exc = self.assertRaises(exception.ResourceTypeNotFound,
|
||||
exc = self.assertRaises(exception.EntityNotFound,
|
||||
resg.validate)
|
||||
exp_msg = 'The Resource Type (idontexist) could not be found.'
|
||||
self.assertIn(exp_msg, six.text_type(exc))
|
||||
|
|
|
@ -396,7 +396,7 @@ class StackResourceTest(StackResourceBaseTest):
|
|||
exc = self.assertRaises(exception.StackValidationFailed,
|
||||
rsrc.validate)
|
||||
else:
|
||||
exc = self.assertRaises(exception.ResourceTypeNotFound,
|
||||
exc = self.assertRaises(exception.EntityNotFound,
|
||||
rsrc.validate)
|
||||
self.assertIn(raise_exc_msg, six.text_type(exc))
|
||||
|
||||
|
|
Loading…
Reference in New Issue