summaryrefslogtreecommitdiff
path: root/heat/engine/resource.py
diff options
context:
space:
mode:
authorZane Bitter <zbitter@redhat.com>2015-11-24 12:29:38 -0500
committerZane Bitter <zbitter@redhat.com>2016-01-18 19:10:30 -0500
commit87116e262329e5cd309a0f1e35ffefd06080022c (patch)
treeee77505201d90e559e7825ba878aa1bf9f671193 /heat/engine/resource.py
parentef2dbfae3ab379e6b4375c8cb1890ff84e49e7e1 (diff)
downloadheat-87116e262329e5cd309a0f1e35ffefd06080022c.tar.gz
Load template files only from their known source
Modify get_class to ensure that user-defined resources cannot result in reads from the local filesystem. Only resources defined by the operator in the global environment should read local files. To make this work, this patch also adds a separate get_class_to_instantiate() method to the Environment. We were previously using get_class for two different purposes - to get a resource plugin on which we could perform introspection to obtain the properties and attributes schema, and to get a resource plugin we could instantiate to create a Resource object. These are both the same except in the case of a TemplateResource, where having two different use cases for the same piece of code was adding considerable extra complexity. Combining the use cases in this way also made the error handling confusing (leading to bug 1518458). This change separates out the two cases. Change-Id: I845e7d23c73242a4a4c9c40599690ab705c75caa Closes-Bug: #1496277 Related-Bug: #1447194 Related-Bug: #1518458 Related-Bug: #1508115 (cherry picked from commit 06a713c4456203cd561f16721dc8ac3bcbb37a3 and 26e6d5f6d776c1027c4f27058767952a58d15e25)
Diffstat (limited to 'heat/engine/resource.py')
-rw-r--r--heat/engine/resource.py11
1 files changed, 3 insertions, 8 deletions
diff --git a/heat/engine/resource.py b/heat/engine/resource.py
index e820692bb..0db8c405e 100644
--- a/heat/engine/resource.py
+++ b/heat/engine/resource.py
@@ -128,15 +128,10 @@ class Resource(object):
# Call is already for a subclass, so pass it through
ResourceClass = cls
else:
- from heat.engine.resources import template_resource
-
registry = stack.env.registry
- try:
- ResourceClass = registry.get_class(definition.resource_type,
- resource_name=name,
- files=stack.t.files)
- except exception.NotFound:
- ResourceClass = template_resource.TemplateResource
+ ResourceClass = registry.get_class_to_instantiate(
+ definition.resource_type,
+ resource_name=name)
assert issubclass(ResourceClass, Resource)