]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
heat engine : Add support for disable_rollback to engine API
authorSteven Hardy <shardy@redhat.com>
Wed, 13 Feb 2013 15:40:30 +0000 (15:40 +0000)
committerSteven Hardy <shardy@redhat.com>
Mon, 18 Feb 2013 14:59:38 +0000 (14:59 +0000)
Adds support for a disable_rollback parameter to the engine API
which will allow us to control rollback of create/update

blueprint stack-rollback

Change-Id: I832f26c917d8fc178b925ce49a2366faf6e3dc0e
Signed-off-by: Steven Hardy <shardy@redhat.com>
heat/engine/api.py
heat/rpc/api.py
heat/tests/test_engine_api_utils.py

index 95d8eb76425773ff74854b832fa1b3e223849850..29bdb4bd361aa2936d35474c8ef23d83090bb55b 100644 (file)
@@ -35,6 +35,14 @@ def extract_args(params):
     else:
         if timeout_mins > 0:
             kwargs[PARAM_TIMEOUT] = timeout_mins
+
+    if PARAM_DISABLE_ROLLBACK in params:
+        disable_rollback = params.get(PARAM_DISABLE_ROLLBACK)
+        if disable_rollback in (True, False):
+            kwargs[PARAM_DISABLE_ROLLBACK] = disable_rollback
+        else:
+            raise ValueError("Unexpected value for parameter %s : %s" %
+                             (PARAM_DISABLE_ROLLBACK, disable_rollback))
     return kwargs
 
 
index ec673057eb001a7161600429aeb025ae232bc5f8..d1ac2453eb3b45a0c264124b305c291244bd72da 100644 (file)
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-PARAM_KEYS = (PARAM_TIMEOUT, ) = ('timeout_mins', )
+PARAM_KEYS = (
+    PARAM_TIMEOUT, PARAM_DISABLE_ROLLBACK
+) = (
+    'timeout_mins', 'disable_rollback'
+)
 
 STACK_KEYS = (
     STACK_NAME, STACK_ID,
index 8e50d212e00cb34481e06c2eba4008749d99c552..6eea86fca575d0fd4b296dd009892b6c8fd3aca8 100644 (file)
@@ -45,3 +45,17 @@ class EngineApiTest(unittest.TestCase):
     def test_timeout_extract_not_present(self):
         args = api.extract_args({})
         self.assertTrue('timeout_mins' not in args)
+
+    def test_disable_rollback_extract_true(self):
+        args = api.extract_args({'disable_rollback': True})
+        self.assertTrue('disable_rollback' in args)
+        self.assertTrue(args.get('disable_rollback'))
+
+    def test_disable_rollback_extract_false(self):
+        args = api.extract_args({'disable_rollback': False})
+        self.assertTrue('disable_rollback' in args)
+        self.assertFalse(args.get('disable_rollback'))
+
+    def test_disable_rollback_extract_bad(self):
+        self.assertRaises(ValueError, api.extract_args,
+                          {'disable_rollback': 'bad'})