'AttributeError',
'ValueError',
'InvalidTenant',
+ 'StackNotFound',
)
if ex.exc_type in inval_param_errors:
error_map = {
'AttributeError': client_error,
'ValueError': client_error,
+ 'StackNotFound': exc.HTTPNotFound,
'InvalidTenant': exc.HTTPForbidden,
}
class InvalidTenant(OpenstackException):
message = _("Searching Tenant %(target)s "
"from Tenant %(actual)s forbidden.")
+
+
+class StackNotFound(OpenstackException):
+ message = _("The Stack (%(stack_name)s) could not be found.")
stack = parser.Stack.load(context, stack=s)
return dict(stack.identifier())
else:
- raise AttributeError('Unknown stack name')
+ raise exception.StackNotFound(stack_name=stack_name)
def _get_stack(self, context, stack_identity):
identity = identifier.HeatIdentifier(**stack_identity)
s = db_api.stack_get(context, identity.stack_id)
if s is None:
- raise AttributeError('Stack not found')
+ raise exception.StackNotFound(stack_name=identity.stack_name)
if identity.path or s.name != identity.stack_name:
- raise AttributeError('Invalid stack ID')
+ raise exception.StackNotFound(stack_name=identity.stack_name)
return s
{'method': 'identify_stack',
'args': {'stack_name': stack_name},
'version': self.api_version}, None
- ).AndRaise(rpc_common.RemoteError("AttributeError"))
+ ).AndRaise(rpc_common.RemoteError("StackNotFound"))
self.m.ReplayAll()
{'method': 'identify_stack',
'args': {'stack_name': stack_name},
'version': self.api_version}, None
- ).AndRaise(rpc_common.RemoteError("AttributeError"))
+ ).AndRaise(rpc_common.RemoteError("StackNotFound"))
self.m.ReplayAll()
{'method': 'identify_stack',
'args': {'stack_name': stack_name},
'version': self.api_version}, None
- ).AndRaise(rpc_common.RemoteError("AttributeError"))
+ ).AndRaise(rpc_common.RemoteError("StackNotFound"))
self.m.ReplayAll()
{'method': 'identify_stack',
'args': {'stack_name': stack_name},
'version': self.api_version}, None
- ).AndRaise(rpc_common.RemoteError("AttributeError"))
+ ).AndRaise(rpc_common.RemoteError("StackNotFound"))
self.m.ReplayAll()
{'method': 'identify_stack',
'args': {'stack_name': stack_name},
'version': self.api_version}, None
- ).AndRaise(rpc_common.RemoteError("AttributeError"))
+ ).AndRaise(rpc_common.RemoteError("StackNotFound"))
self.m.ReplayAll()
self.assertEqual(response, expected)
+ def test_describe_stack_resource_nonexistent_stack(self):
+ # Format a dummy request
+ stack_name = "wibble"
+ identity = dict(identifier.HeatIdentifier('t', stack_name, '6'))
+ params = {'Action': 'DescribeStackResource',
+ 'StackName': stack_name,
+ 'LogicalResourceId': "WikiDatabase"}
+ dummy_req = self._dummy_GET_request(params)
+
+ # Stub out the RPC call to the engine with a pre-canned response
+ self.m.StubOutWithMock(rpc, 'call')
+ rpc.call(dummy_req.context, self.topic,
+ {'method': 'identify_stack',
+ 'args': {'stack_name': stack_name},
+ 'version': self.api_version},
+ None).AndRaise(rpc_common.RemoteError("StackNotFound"))
+
+ self.m.ReplayAll()
+
+ result = self.controller.describe_stack_resource(dummy_req)
+ self.assertEqual(type(result),
+ exception.HeatInvalidParameterValueError)
+
def test_describe_stack_resources(self):
# Format a dummy request
stack_name = "wordpress"
{'method': 'identify_stack',
'args': {'stack_name': stack_name},
'version': self.api_version}, None
- ).AndRaise(rpc_common.RemoteError("AttributeError"))
+ ).AndRaise(rpc_common.RemoteError("StackNotFound"))
self.m.ReplayAll()
{'method': 'identify_stack',
'args': {'stack_name': stack_name},
'version': self.api_version}, None
- ).AndRaise(rpc_common.RemoteError("AttributeError"))
+ ).AndRaise(rpc_common.RemoteError("StackNotFound"))
self.m.ReplayAll()
{'method': 'identify_stack',
'args': {'stack_name': stack_name},
'version': self.api_version},
- None).AndRaise(rpc_common.RemoteError("AttributeError"))
+ None).AndRaise(rpc_common.RemoteError("StackNotFound"))
self.m.ReplayAll()
self.assertRaises(webob.exc.HTTPNotFound, self.controller.lookup,
{'method': 'identify_stack',
'args': {'stack_name': stack_name},
'version': self.api_version},
- None).AndRaise(rpc_common.RemoteError("AttributeError"))
+ None).AndRaise(rpc_common.RemoteError("StackNotFound"))
self.m.ReplayAll()
self.assertRaises(webob.exc.HTTPNotFound, self.controller.lookup,
self.assertEqual(response, expected)
self.m.VerifyAll()
- def test_show_aterr(self):
- identity = identifier.HeatIdentifier(self.tenant, 'wordpress', '6')
+ def test_show_notfound(self):
+ identity = identifier.HeatIdentifier(self.tenant, 'wibble', '6')
req = self._get('/stacks/%(stack_name)s/%(stack_id)s' % identity)
{'method': 'show_stack',
'args': {'stack_identity': dict(identity)},
'version': self.api_version},
- None).AndRaise(rpc_common.RemoteError("AttributeError"))
+ None).AndRaise(rpc_common.RemoteError("StackNotFound"))
self.m.ReplayAll()
self.assertRaises(webob.exc.HTTPNotFound,
self.assertEqual(response, template)
self.m.VerifyAll()
- def test_get_template_err_rpcerr(self):
+ def test_get_template_err_notfound(self):
identity = identifier.HeatIdentifier(self.tenant, 'wordpress', '6')
req = self._get('/stacks/%(stack_name)s/%(stack_id)s' % identity)
template = {u'Foo': u'bar'}
{'method': 'get_template',
'args': {'stack_identity': dict(identity)},
'version': self.api_version},
- None).AndRaise(rpc_common.RemoteError("AttributeError"))
+ None).AndRaise(rpc_common.RemoteError("StackNotFound"))
self.m.ReplayAll()
'params': parameters,
'args': {'timeout_mins': 30}},
'version': self.api_version},
- None).AndRaise(rpc_common.RemoteError("AttributeError"))
+ None).AndRaise(rpc_common.RemoteError("StackNotFound"))
self.m.ReplayAll()
self.assertRaises(webob.exc.HTTPNotFound,
{'method': 'delete_stack',
'args': {'stack_identity': dict(identity)},
'version': self.api_version},
- None).AndRaise(rpc_common.RemoteError("AttributeError"))
+ None).AndRaise(rpc_common.RemoteError("StackNotFound"))
self.m.ReplayAll()
self.assertRaises(webob.exc.HTTPNotFound,
{'method': 'list_stack_resources',
'args': {'stack_identity': stack_identity},
'version': self.api_version},
- None).AndRaise(rpc_common.RemoteError("AttributeError"))
+ None).AndRaise(rpc_common.RemoteError("StackNotFound"))
self.m.ReplayAll()
self.assertRaises(webob.exc.HTTPNotFound,
'args': {'stack_identity': stack_identity,
'resource_name': res_name},
'version': self.api_version},
- None).AndRaise(rpc_common.RemoteError("AttributeError"))
+ None).AndRaise(rpc_common.RemoteError("StackNotFound"))
self.m.ReplayAll()
self.assertRaises(webob.exc.HTTPNotFound,
'args': {'stack_identity': stack_identity,
'resource_name': res_name},
'version': self.api_version},
- None).AndRaise(rpc_common.RemoteError("AttributeError"))
+ None).AndRaise(rpc_common.RemoteError("StackNotFound"))
self.m.ReplayAll()
self.assertRaises(webob.exc.HTTPNotFound,
{'method': 'list_events',
'args': {'stack_identity': stack_identity},
'version': self.api_version},
- None).AndRaise(rpc_common.RemoteError("AttributeError"))
+ None).AndRaise(rpc_common.RemoteError("StackNotFound"))
self.m.ReplayAll()
self.assertRaises(webob.exc.HTTPNotFound,
{'method': 'list_events',
'args': {'stack_identity': stack_identity},
'version': self.api_version},
- None).AndRaise(rpc_common.RemoteError("AttributeError"))
+ None).AndRaise(rpc_common.RemoteError("StackNotFound"))
self.m.ReplayAll()
self.assertRaises(webob.exc.HTTPNotFound,
self.m.ReplayAll()
- self.assertRaises(AttributeError,
+ self.assertRaises(exception.StackNotFound,
self.man.delete_stack,
self.ctx, stack.identifier())
self.m.VerifyAll()
self.m.ReplayAll()
- self.assertRaises(AttributeError,
+ self.assertRaises(exception.StackNotFound,
self.man.update_stack,
self.ctx, stack.identifier(), template, params, {})
self.m.VerifyAll()
self.assertEqual(identity, self.stack_identity)
def test_stack_identify_nonexist(self):
- self.assertRaises(AttributeError, self.man.identify_stack,
+ self.assertRaises(exception.StackNotFound, self.man.identify_stack,
self.ctx, 'wibble')
def test_stack_create_existing(self):
def test_stack_describe_nonexistent(self):
nonexist = dict(self.stack_identity)
nonexist['stack_name'] = 'wibble'
- self.assertRaises(AttributeError,
+ self.assertRaises(exception.StackNotFound,
self.man.show_stack,
self.ctx, nonexist)
def test_stack_resource_describe_nonexist_stack(self):
nonexist = dict(self.stack_identity)
nonexist['stack_name'] = 'foo'
- self.assertRaises(AttributeError,
+ self.assertRaises(exception.StackNotFound,
self.man.describe_stack_resource,
self.ctx, nonexist, 'WebServer')
def test_stack_resources_describe_nonexist_stack(self):
nonexist = dict(self.stack_identity)
nonexist['stack_name'] = 'foo'
- self.assertRaises(AttributeError,
+ self.assertRaises(exception.StackNotFound,
self.man.describe_stack_resources,
self.ctx, nonexist, 'WebServer')
def test_stack_resources_list_nonexist_stack(self):
nonexist = dict(self.stack_identity)
nonexist['stack_name'] = 'foo'
- self.assertRaises(AttributeError,
+ self.assertRaises(exception.StackNotFound,
self.man.list_stack_resources,
self.ctx, nonexist)
test_metadata = {'foo': 'bar', 'baz': 'quux', 'blarg': 'wibble'}
nonexist = dict(self.stack_identity)
nonexist['stack_name'] = 'foo'
- self.assertRaises(AttributeError,
+ self.assertRaises(exception.StackNotFound,
self.man.metadata_update,
self.ctx, nonexist,
'WebServer', test_metadata)