From b1e5bde791e106d5857cbf7ed16330f3afcdff2d Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Wed, 13 Feb 2013 15:40:30 +0000 Subject: [PATCH] heat engine : Add support for disable_rollback to engine API 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 --- heat/engine/api.py | 8 ++++++++ heat/rpc/api.py | 6 +++++- heat/tests/test_engine_api_utils.py | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/heat/engine/api.py b/heat/engine/api.py index 95d8eb76..29bdb4bd 100644 --- a/heat/engine/api.py +++ b/heat/engine/api.py @@ -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 diff --git a/heat/rpc/api.py b/heat/rpc/api.py index ec673057..d1ac2453 100644 --- a/heat/rpc/api.py +++ b/heat/rpc/api.py @@ -12,7 +12,11 @@ # 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, diff --git a/heat/tests/test_engine_api_utils.py b/heat/tests/test_engine_api_utils.py index 8e50d212..6eea86fc 100644 --- a/heat/tests/test_engine_api_utils.py +++ b/heat/tests/test_engine_api_utils.py @@ -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'}) -- 2.45.2