From 2407c8643689042f1ab9cd582af477bdc3a9860f Mon Sep 17 00:00:00 2001 From: rabi Date: Wed, 2 Nov 2016 08:41:54 +0530 Subject: [PATCH] Ignore merged env if environment files are specified Ignore merged environment from the client, if there are 'environment_files' in the request for merging in the server. This would avoid the duplicates when 'parameter_merge_strategies' are specified in the first env file. Change-Id: I4ee274d69e42a47c4b8fd5a25567fb2eb144a8cc Related-Bug: #1635409 --- heat/api/openstack/v1/stacks.py | 4 +++- heat/tests/api/openstack_v1/test_stacks.py | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/heat/api/openstack/v1/stacks.py b/heat/api/openstack/v1/stacks.py index 237f3e566a..21fdff96a8 100644 --- a/heat/api/openstack/v1/stacks.py +++ b/heat/api/openstack/v1/stacks.py @@ -137,7 +137,9 @@ class InstantiationData(object): environment global options. """ env = {} - if self.PARAM_ENVIRONMENT in self.data: + # Don't use merged environment, if environment_files are supplied. + if (self.PARAM_ENVIRONMENT in self.data and + not self.data.get(self.PARAM_ENVIRONMENT_FILES)): env_data = self.data[self.PARAM_ENVIRONMENT] with self.parse_error_check('Environment'): if isinstance(env_data, dict): diff --git a/heat/tests/api/openstack_v1/test_stacks.py b/heat/tests/api/openstack_v1/test_stacks.py index ed311b519d..9708329f8d 100644 --- a/heat/tests/api/openstack_v1/test_stacks.py +++ b/heat/tests/api/openstack_v1/test_stacks.py @@ -167,6 +167,17 @@ blarg: wibble data = stacks.InstantiationData(body) self.assertEqual(env, data.environment()) + def test_environment_with_env_files(self): + env = {'parameters': {'foo': 'bar', 'blarg': 'wibble'}} + body = {'environment': env, 'environment_files': ['env.yaml']} + expect = {'parameters': {}, + 'encrypted_param_names': [], + 'parameter_defaults': {}, + 'event_sinks': [], + 'resource_registry': {}} + data = stacks.InstantiationData(body) + self.assertEqual(expect, data.environment()) + def test_environment_and_parameters(self): body = {'parameters': {'foo': 'bar'}, 'environment': {'parameters': {'blarg': 'wibble'}}}