if stack is not None:
stack.delete()
+ def handle_suspend(self):
+ stack = self.nested()
+ if stack is None:
+ raise exception.Error(_('Cannot suspend %s, stack not created')
+ % self.name)
+
+ suspend_task = scheduler.TaskRunner(self._nested.suspend_task)
+ suspend_task.start(timeout=self._nested.timeout_secs())
+ return suspend_task
+
+ def check_suspend_complete(self, suspend_task):
+ done = suspend_task.step()
+ if done:
+ if self._nested.state != (self._nested.SUSPEND,
+ self._nested.COMPLETE):
+ raise exception.Error(self._nested.status_reason)
+
+ return done
+
def get_output(self, op):
'''
Return the specified Output value from the nested stack.
from heat.common import template_format
from heat.engine import parser
from heat.engine import resource
+from heat.engine import scheduler
from heat.common import urlfetch
from heat.tests.common import HeatTestCase
from heat.tests import utils
self.assertTrue(rsrc.FnGetRefId().startswith(arn_prefix))
self.m.VerifyAll()
+
+ def test_nested_stack_suspend(self):
+ urlfetch.get('https://localhost/the.template').AndReturn(
+ self.nested_template)
+ self.m.ReplayAll()
+
+ stack = self.create_stack(self.test_template)
+ rsrc = stack['the_nested']
+
+ scheduler.TaskRunner(rsrc.suspend)()
+ self.assertEqual(rsrc.state, (rsrc.SUSPEND, rsrc.COMPLETE))
+
+ rsrc.delete()
+ self.m.VerifyAll()