diff --git a/etc/heat/heat.conf.sample b/etc/heat/heat.conf.sample index 5443645c3e..cce2683405 100644 --- a/etc/heat/heat.conf.sample +++ b/etc/heat/heat.conf.sample @@ -74,6 +74,12 @@ # value) #enable_cloud_watch_lite=true +# Enable the preview Stack Abandon feature. (boolean value) +#enable_stack_abandon=false + +# Enable the preview Stack Adopt feature. (boolean value) +#enable_stack_adopt=false + # Deprecated. (string value) #onready= diff --git a/heat/common/config.py b/heat/common/config.py index 1274faa0c7..dfc96960de 100644 --- a/heat/common/config.py +++ b/heat/common/config.py @@ -140,6 +140,12 @@ engine_opts = [ cfg.BoolOpt('enable_cloud_watch_lite', default=True, help=_('Enable the legacy OS::Heat::CWLiteAlarm resource.')), + cfg.BoolOpt('enable_stack_abandon', + default=False, + help=_('Enable the preview Stack Abandon feature.')), + cfg.BoolOpt('enable_stack_adopt', + default=False, + help=_('Enable the preview Stack Adopt feature.')), cfg.StrOpt('onready', help=_('Deprecated.'))] diff --git a/heat/engine/service.py b/heat/engine/service.py index b2909c8523..b2f329db00 100644 --- a/heat/engine/service.py +++ b/heat/engine/service.py @@ -54,6 +54,8 @@ from heat.rpc import api as rpc_api cfg.CONF.import_opt('engine_life_check_timeout', 'heat.common.config') cfg.CONF.import_opt('max_resources_per_stack', 'heat.common.config') cfg.CONF.import_opt('max_stacks_per_tenant', 'heat.common.config') +cfg.CONF.import_opt('enable_stack_abandon', 'heat.common.config') +cfg.CONF.import_opt('enable_stack_adopt', 'heat.common.config') LOG = logging.getLogger(__name__) @@ -596,6 +598,9 @@ class EngineService(service.Service): # Create/Adopt a stack, and create the periodic task if successful if stack.adopt_stack_data: + if not cfg.CONF.enable_stack_adopt: + raise exception.NotSupported(feature='Stack Adopt') + stack.adopt() else: stack.create() @@ -876,6 +881,9 @@ class EngineService(service.Service): :param cnxt: RPC context. :param stack_identity: Name of the stack you want to abandon. """ + if not cfg.CONF.enable_stack_abandon: + raise exception.NotSupported(feature='Stack Abandon') + st = self._get_stack(cnxt, stack_identity) LOG.info(_('abandoning stack %s') % st.name) stack = parser.Stack.load(cnxt, stack=st) diff --git a/heat/tests/test_engine_service.py b/heat/tests/test_engine_service.py index 1954269135..1d01573030 100644 --- a/heat/tests/test_engine_service.py +++ b/heat/tests/test_engine_service.py @@ -55,6 +55,7 @@ from heat.tests import utils from heat.tests.v1_1 import fakes cfg.CONF.import_opt('engine_life_check_timeout', 'heat.common.config') +cfg.CONF.import_opt('enable_stack_abandon', 'heat.common.config') wp_template = ''' { @@ -2023,6 +2024,7 @@ class StackServiceTest(HeatTestCase): @stack_context('service_abandon_stack') def test_abandon_stack(self): + cfg.CONF.set_override('enable_stack_abandon', True) self.m.StubOutWithMock(parser.Stack, 'load') parser.Stack.load(self.ctx, stack=mox.IgnoreArg()).AndReturn(self.stack)