]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Add a "rollback" parameter to StackUpdate
authorZane Bitter <zbitter@redhat.com>
Mon, 26 Aug 2013 19:11:59 +0000 (21:11 +0200)
committerZane Bitter <zbitter@redhat.com>
Mon, 26 Aug 2013 19:11:59 +0000 (21:11 +0200)
We can only consider restoring backup resources during a rollback
operation. If they are present during a standard update, there is no way of
testing whether or not they match the new template definition, so we need
to treat them differently in this case.

Change-Id: Ibd73ed047486c253a6c06b7340a3a591f0fee3db

heat/engine/parser.py
heat/engine/update.py

index 8ee8dc898f652790d78f3565bcb7d7b3cf88b155..99e984eaf40b50067a094c203f67e5e3ae7517cc 100644 (file)
@@ -410,7 +410,8 @@ class Stack(object):
         backup_stack = self._backup_stack()
 
         try:
-            update_task = update.StackUpdate(self, newstack, backup_stack)
+            update_task = update.StackUpdate(self, newstack, backup_stack,
+                                             rollback=action == self.ROLLBACK)
             updater = scheduler.TaskRunner(update_task)
 
             self.env = newstack.env
index 5e44a5071a7268086fc674465639debc31f3c7b6..9ccbef5d9e3f6b1271681e02b52b22161b76911a 100644 (file)
@@ -26,17 +26,23 @@ class StackUpdate(object):
     A Task to perform the update of an existing stack to a new template.
     """
 
-    def __init__(self, existing_stack, new_stack, previous_stack):
+    def __init__(self, existing_stack, new_stack, previous_stack,
+                 rollback=False):
         """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.rollback = rollback
+
         self.existing_snippets = dict((r.name, r.parsed_template())
                                       for r in self.existing_stack)
 
     def __repr__(self):
-        return '%s Update' % str(self.existing_stack)
+        if self.rollback:
+            return '%s Rollback' % str(self.existing_stack)
+        else:
+            return '%s Update' % str(self.existing_stack)
 
     @scheduler.wrappertask
     def __call__(self):