Add check_adopt_complete to the stack_resource
NestedStack was hiding adopt failures from the user. We have identical versions of check_adopt_complete in template_resource and resource_group, so just move it to the base class to catch all the nested stack implementations. Change-Id: I07f3943b56fb925e550246b41df2956655869301 Closes-bug: 1416934
This commit is contained in:
parent
734f777da4
commit
6b520b2cd1
|
@ -346,17 +346,6 @@ class ResourceGroup(stack_resource.StackResource):
|
|||
{},
|
||||
adopt_data=resource_data)
|
||||
|
||||
def check_adopt_complete(self, adopter):
|
||||
if adopter is None:
|
||||
return True
|
||||
done = adopter.step()
|
||||
if done:
|
||||
if self._nested.state != (self._nested.ADOPT,
|
||||
self._nested.COMPLETE):
|
||||
raise exception.Error(self._nested.status_reason)
|
||||
|
||||
return done
|
||||
|
||||
|
||||
def resource_mapping():
|
||||
return {
|
||||
|
|
|
@ -244,15 +244,6 @@ class TemplateResource(stack_resource.StackResource):
|
|||
self.child_params(),
|
||||
adopt_data=resource_data)
|
||||
|
||||
def check_adopt_complete(self, stack_creator):
|
||||
done = stack_creator.step()
|
||||
if done:
|
||||
if self._nested.state != (self._nested.ADOPT,
|
||||
self._nested.COMPLETE):
|
||||
raise exception.Error(self._nested.status_reason)
|
||||
|
||||
return done
|
||||
|
||||
def handle_create(self):
|
||||
return self.create_with_template(self.child_template(),
|
||||
self.child_params())
|
||||
|
|
|
@ -241,6 +241,17 @@ class StackResource(resource.Resource):
|
|||
|
||||
return done
|
||||
|
||||
def check_adopt_complete(self, stack_creator):
|
||||
if stack_creator is None:
|
||||
return True
|
||||
done = stack_creator.step()
|
||||
if done:
|
||||
if self._nested.state != (self._nested.ADOPT,
|
||||
self._nested.COMPLETE):
|
||||
raise exception.Error(self._nested.status_reason)
|
||||
|
||||
return done
|
||||
|
||||
def update_with_template(self, child_template, user_params=None,
|
||||
timeout_mins=None):
|
||||
"""Update the nested stack with the new template."""
|
||||
|
|
|
@ -193,7 +193,10 @@ Outputs:
|
|||
}
|
||||
}
|
||||
|
||||
stack = self.adopt_stack(self.test_template, adopt_data)
|
||||
t = template_format.parse(self.test_template)
|
||||
stack = self.parse_stack(t, adopt_data)
|
||||
stack.adopt()
|
||||
self.assertEqual((stack.ADOPT, stack.FAILED), stack.state)
|
||||
rsrc = stack['the_nested']
|
||||
self.assertEqual((rsrc.ADOPT, rsrc.FAILED), rsrc.nested().state)
|
||||
nested_name = utils.PhysName(stack.name, 'the_nested')
|
||||
|
|
Loading…
Reference in New Issue