]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Pass the previous stack to StackUpdate
authorZane Bitter <zbitter@redhat.com>
Thu, 22 Aug 2013 11:01:21 +0000 (13:01 +0200)
committerZane Bitter <zbitter@redhat.com>
Thu, 22 Aug 2013 12:59:51 +0000 (14:59 +0200)
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
heat/engine/update.py

index 56a60b6b0eccb33d28a4688939ad064dfc656231..70a343f31673d7b8b46c342e771c52bfb425fbf8 100644 (file)
@@ -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
 
index 85cf62fb2c22c884f0c2e50e5853620f1f54e6de..5e44a5071a7268086fc674465639debc31f3c7b6 100644 (file)
@@ -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)