From f2e9b31a965e3ef0168da1f9dc65afb2d8e24810 Mon Sep 17 00:00:00 2001 From: Zane Bitter Date: Thu, 22 Aug 2013 13:01:21 +0200 Subject: [PATCH] Pass the previous stack to StackUpdate This starts out like the existing stack, but is not stored in the database or updated as the stack update proceeds. This allows the StackUpdate object to store any information that might be relevant to a future rollback. Change-Id: I94f0dd69b5e7818f811c8c0d50566a79b81acba7 --- heat/engine/parser.py | 13 ++++++------- heat/engine/update.py | 3 ++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/heat/engine/parser.py b/heat/engine/parser.py index 56a60b6b..70a343f3 100644 --- a/heat/engine/parser.py +++ b/heat/engine/parser.py @@ -383,16 +383,17 @@ class Stack(object): 'State invalid for %s' % action) return - current_env = self.env - self.env = newstack.env - self.parameters = newstack.parameters - self.state_set(self.UPDATE, self.IN_PROGRESS, 'Stack %s started' % action) + oldstack = Stack(self.context, self.name, self.t, self.env) try: - update_task = update.StackUpdate(self, newstack) + update_task = update.StackUpdate(self, newstack, oldstack) updater = scheduler.TaskRunner(update_task) + + self.env = newstack.env + self.parameters = newstack.parameters + try: updater(timeout=self.timeout_secs()) finally: @@ -416,8 +417,6 @@ class Stack(object): # If rollback is enabled, we do another update, with the # existing template, so we roll back to the original state if not self.disable_rollback: - oldstack = Stack(self.context, self.name, self.t, - current_env) self.update(oldstack, action=self.ROLLBACK) return diff --git a/heat/engine/update.py b/heat/engine/update.py index 85cf62fb..5e44a507 100644 --- a/heat/engine/update.py +++ b/heat/engine/update.py @@ -26,10 +26,11 @@ class StackUpdate(object): A Task to perform the update of an existing stack to a new template. """ - def __init__(self, existing_stack, new_stack): + def __init__(self, existing_stack, new_stack, previous_stack): """Initialise with the existing stack and the new stack.""" self.existing_stack = existing_stack self.new_stack = new_stack + self.previous_stack = previous_stack self.existing_snippets = dict((r.name, r.parsed_template()) for r in self.existing_stack) -- 2.45.2