From 95a5fd14efd09eda5d78c4c41cc16279647c37f7 Mon Sep 17 00:00:00 2001 From: Vitaly Gridnev Date: Wed, 16 Sep 2015 15:25:40 +0300 Subject: [PATCH] Heat stack creation with tags Sahara should create heat stack with tags to hide these stack from users. Change-Id: I7656608ae4e8d24eca7eaf6e186ea3f5cbf1d02d Closes-bug: 1495991 --- sahara/config.py | 4 +++- sahara/service/heat/heat_engine.py | 7 +++++++ sahara/service/heat/templates.py | 3 +++ sahara/utils/openstack/heat.py | 3 ++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/sahara/config.py b/sahara/config.py index 336374be..f34a7a10 100644 --- a/sahara/config.py +++ b/sahara/config.py @@ -129,6 +129,7 @@ def list_opts(): from sahara.conductor import api from sahara import main as sahara_main from sahara.service.edp import job_utils + from sahara.service.heat import heat_engine from sahara.service import periodic from sahara.utils import cluster_progress_ops as cpo from sahara.utils.openstack import base @@ -157,7 +158,8 @@ def list_opts(): proxy.opts, cpo.event_log_opts, wsgi.wsgi_opts, - base.opts)), + base.opts, + heat_engine.heat_engine_opts)), (poll_utils.timeouts.name, itertools.chain(poll_utils.timeouts_opts)), (api.conductor_group.name, diff --git a/sahara/service/heat/heat_engine.py b/sahara/service/heat/heat_engine.py index a6214b18..444e7c43 100644 --- a/sahara/service/heat/heat_engine.py +++ b/sahara/service/heat/heat_engine.py @@ -42,6 +42,13 @@ ROLLBACK_STAGES = [c_u.CLUSTER_STATUS_ROLLBACK_SPAWNING, c_u.CLUSTER_STATUS_ROLLBACK_WAITING, c_u.CLUSTER_STATUS_ROLLBACK__PREPARING] +heat_engine_opts = [ + cfg.ListOpt('heat_stack_tags', default=['data-processing-cluster'], + help="List of tags to be used during operating with stack.") +] + +CONF.register_opts(heat_engine_opts) + class HeatEngine(e.Engine): def get_type_and_version(self): diff --git a/sahara/service/heat/templates.py b/sahara/service/heat/templates.py index 2d581ebb..e1442e3e 100644 --- a/sahara/service/heat/templates.py +++ b/sahara/service/heat/templates.py @@ -126,6 +126,9 @@ class ClusterStack(object): 'template': main_tmpl, 'files': self.files} + if CONF.heat_stack_tags: + kwargs['tags'] = ",".join(CONF.heat_stack_tags) + if not update_existing: LOG.debug("Creating Heat stack with args: {args}" .format(args=kwargs)) diff --git a/sahara/utils/openstack/heat.py b/sahara/utils/openstack/heat.py index eed05fe5..09f2511e 100644 --- a/sahara/utils/openstack/heat.py +++ b/sahara/utils/openstack/heat.py @@ -55,7 +55,8 @@ def client(): def get_stack(stack_name, raise_on_missing=True): for stack in base.execute_with_retries( - client().stacks.list, filters={'name': stack_name}): + client().stacks.list, show_hidden=True, + filters={'name': stack_name}): return stack if not raise_on_missing: