diff options
author | ricolin <rico.lin@easystack.cn> | 2017-07-08 01:56:59 +0800 |
---|---|---|
committer | ricolin <rico.lin@easystack.cn> | 2017-08-18 10:59:53 +0800 |
commit | 5f21edfc7116b26edf3d7f7ec6a660a014d98261 (patch) | |
tree | ec242c46618ab7a873b5bdf0880bdca0a4ec8576 | |
parent | f99b95742d363f70f7e7bee40ef15e6459179190 (diff) | |
download | heat-5f21edfc7116b26edf3d7f7ec6a660a014d98261.tar.gz |
Allow only validate external resource template
When we choose only validate resource template, and external resource
id was set, we should consider that external resource template is
valid (since we only required `external_id` from that resource
template format). So the result of this validate will be None
(template validate passed).
Closes-Bug: #1702977
Change-Id: I8b33c957a7185a0f52356f412b13609ba1a7b469
(cherry picked from commit 7cbf528da514e8830b9d1b211cf6d9554a9d6128)
-rw-r--r-- | heat/engine/stack.py | 1 | ||||
-rw-r--r-- | heat/tests/test_validate.py | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/heat/engine/stack.py b/heat/engine/stack.py index 4982fc49a..ad2ab6e2c 100644 --- a/heat/engine/stack.py +++ b/heat/engine/stack.py @@ -845,6 +845,7 @@ class Stack(collections.Mapping): # Don't validate identical definitions multiple times if res.name not in unique_defn_names: continue + result = None try: if self.resource_validate: if res.external_id is not None: diff --git a/heat/tests/test_validate.py b/heat/tests/test_validate.py index 0fc53feb3..51b505387 100644 --- a/heat/tests/test_validate.py +++ b/heat/tests/test_validate.py @@ -899,6 +899,16 @@ outputs: ''' +test_template_external_rsrc = ''' +heat_template_version: ocata + +resources: + random_str: + type: OS::Nova::Server + external_id: foobar +''' + + class ValidateTest(common.HeatTestCase): def setUp(self): super(ValidateTest, self).setUp() @@ -1746,3 +1756,14 @@ class ValidateTest(common.HeatTestCase): ex = webob.exc.HTTPBadRequest(explanation=msg) self.assertIsInstance(res, webob.exc.HTTPBadRequest) self.assertEqual(ex.explanation, res.explanation) + + def test_validate_allowed_external_rsrc(self): + t = template_format.parse(test_template_external_rsrc) + template = tmpl.Template(t) + stack = parser.Stack(self.ctx, 'test_stack', template) + + with mock.patch( + 'heat.engine.resources.server_base.BaseServer._show_resource', + return_value={'id': 'foobar'} + ): + self.assertIsNone(stack.validate()) |