Return available info for uncreated resource
The resource show API verified that a resource is defined in stack and has an id associated with it. Because of this, for a valid stack resource which is not persisted, the resource show API returned the error 'stack or resource not found'. Fixed by validating only that the resource is defined in a stack and return the available information in the resource show API response. Change-Id: Ic0a031294f4f1dffc3c9978014480d15fd2fa27b Closes-bug: #1402531
This commit is contained in:
parent
945f5d0554
commit
207872b060
|
@ -1028,7 +1028,9 @@ class EngineService(service.Service):
|
|||
LOG.warn(_LW("Access denied to resource %s"), resource_name)
|
||||
raise exception.Forbidden()
|
||||
|
||||
self._verify_stack_resource(stack, resource_name)
|
||||
if resource_name not in stack:
|
||||
raise exception.ResourceNotFound(resource_name=resource_name,
|
||||
stack_name=stack.name)
|
||||
|
||||
return api.format_stack_resource(stack[resource_name],
|
||||
with_attr=with_attr)
|
||||
|
|
|
@ -2222,8 +2222,7 @@ class StackServiceTest(common.HeatTestCase):
|
|||
msg = 'The Resource Type (Bogus) could not be found.'
|
||||
self.assertEqual(msg, six.text_type(ex))
|
||||
|
||||
@stack_context('service_stack_resource_describe__test_stack')
|
||||
def test_stack_resource_describe(self):
|
||||
def _test_describe_stack_resource(self):
|
||||
self.m.StubOutWithMock(parser.Stack, 'load')
|
||||
parser.Stack.load(self.ctx,
|
||||
stack=mox.IgnoreArg()).AndReturn(self.stack)
|
||||
|
@ -2250,6 +2249,10 @@ class StackServiceTest(common.HeatTestCase):
|
|||
|
||||
self.m.VerifyAll()
|
||||
|
||||
@stack_context('service_stack_resource_describe__test_stack')
|
||||
def test_stack_resource_describe(self):
|
||||
self._test_describe_stack_resource()
|
||||
|
||||
def test_stack_resource_describe_nonexist_stack(self):
|
||||
non_exist_identifier = identifier.HeatIdentifier(
|
||||
self.ctx.tenant_id,
|
||||
|
@ -2283,6 +2286,11 @@ class StackServiceTest(common.HeatTestCase):
|
|||
|
||||
self.m.VerifyAll()
|
||||
|
||||
@stack_context('service_resource_describe_noncreated_test_stack',
|
||||
create_res=False)
|
||||
def test_stack_resource_describe_noncreated_resource(self):
|
||||
self._test_describe_stack_resource()
|
||||
|
||||
@stack_context('service_resource_describe_user_deny_test_stack')
|
||||
def test_stack_resource_describe_stack_user_deny(self):
|
||||
self.ctx.roles = [cfg.CONF.heat_stack_user_role]
|
||||
|
|
Loading…
Reference in New Issue