From a02ff20509171346d2a1d2a9df7c81aada134c52 Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Thu, 1 May 2014 11:20:55 +1000 Subject: [PATCH] Don't dynamically create provider types in the global env Only support this in user environments. Note: this is only when you have the following in your template resources: thingy: type: http://example.com/foo.template Doing this will avoid tenant-specific provider template URLs being shown globally in the resource-type listing. Co-Authored-By: Angus Salkeld Closes-Bug: #1311223 Change-Id: Ifa18108afacbda390b19b46a8f41bc4f018e95d6 --- heat/engine/environment.py | 5 ++++- heat/tests/test_provider_template.py | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/heat/engine/environment.py b/heat/engine/environment.py index 23bdd70661..e29e56a533 100644 --- a/heat/engine/environment.py +++ b/heat/engine/environment.py @@ -217,7 +217,10 @@ class ResourceRegistry(object): registry[name] = info def iterable_by(self, resource_type, resource_name=None): - if resource_type.endswith(('.yaml', '.template')): + is_templ_type = resource_type.endswith(('.yaml', '.template')) + if self.global_registry is not None and is_templ_type: + # we only support dynamic resource types in user environments + # not the global environment. # resource with a Type == a template # we dynamically create an entry as it has not been registered. if resource_type not in self._registry: diff --git a/heat/tests/test_provider_template.py b/heat/tests/test_provider_template.py index 5d7b1a635e..fab9859577 100644 --- a/heat/tests/test_provider_template.py +++ b/heat/tests/test_provider_template.py @@ -428,6 +428,8 @@ class ProviderTemplateTest(HeatTestCase): {'WordPress_Single_Instance.yaml': 'WordPress_Single_Instance.yaml', 'resources': {}}, stack.env.user_env_as_dict()["resource_registry"]) + self.assertNotIn('WordPress_Single_Instance.yaml', + resources.global_env().registry._registry) def test_persisted_unregistered_provider_templates(self): """