From b797457a1ac82ff28677abbd2b827e3b3567ad0b Mon Sep 17 00:00:00 2001 From: Thomas Herve Date: Mon, 11 Jan 2016 14:23:00 +0100 Subject: [PATCH] Don't wait for undefined actions in SoftwareComponent This skips deploying a configuration on SoftwareDeployment if the associated SoftwareComponent doesn't define a script for the action. Change-Id: I9353cfd92bdcedfab6c8559e7a96425f09a1f6f0 Closes-Bug: #1532784 --- .../openstack/heat/software_deployment.py | 10 +++-- .../heat/test_software_deployment.py | 37 +++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/heat/engine/resources/openstack/heat/software_deployment.py b/heat/engine/resources/openstack/heat/software_deployment.py index cdf6a7b1b..77e4e5d28 100644 --- a/heat/engine/resources/openstack/heat/software_deployment.py +++ b/heat/engine/resources/openstack/heat/software_deployment.py @@ -248,9 +248,13 @@ class SoftwareDeployment(signal_responder.SignalResponder): else: config = {} - if (action not in self.properties[self.DEPLOY_ACTIONS] - and not config.get( - rpc_api.SOFTWARE_CONFIG_GROUP) == 'component'): + if config.get(rpc_api.SOFTWARE_CONFIG_GROUP) == 'component': + valid_actions = set() + for conf in config['config']['configs']: + valid_actions.update(conf['actions']) + if action not in valid_actions: + return + elif action not in self.properties[self.DEPLOY_ACTIONS]: return props = self._build_properties( diff --git a/heat/tests/openstack/heat/test_software_deployment.py b/heat/tests/openstack/heat/test_software_deployment.py index 79ad669a5..409a732da 100644 --- a/heat/tests/openstack/heat/test_software_deployment.py +++ b/heat/tests/openstack/heat/test_software_deployment.py @@ -982,6 +982,43 @@ class SoftwareDeploymentTest(common.HeatTestCase): self.assertIsNotNone(self.deployment.handle_resume()) self.assertIsNotNone(self.deployment.handle_delete()) + def test_handle_unused_action_for_component(self): + self._create_stack(self.template) + + config = { + 'id': '48e8ade1-9196-42d5-89a2-f709fde42632', + 'group': 'component', + 'name': 'myconfig', + 'config': { + 'configs': [ + { + 'actions': ['CREATE'], + 'config': 'the config', + 'tool': 'a_tool' + } + ] + }, + 'options': {}, + 'inputs': [{ + 'name': 'foo', + 'type': 'String', + 'default': 'baa', + }, { + 'name': 'bar', + 'type': 'String', + 'default': 'baz', + }], + 'outputs': [], + } + self.rpc_client.show_software_config.return_value = config + sd = self.mock_deployment() + + self.rpc_client.show_software_deployment.return_value = sd + self.deployment.resource_id = sd['id'] + + self.assertIsNotNone(self.deployment.handle_create()) + self.assertIsNone(self.deployment.handle_delete()) + def test_get_temp_url(self): dep_data = {}