diff options
author | ramishra <ramishra@redhat.com> | 2021-03-16 11:24:09 +0530 |
---|---|---|
committer | rabi <ramishra@redhat.com> | 2022-11-15 09:35:38 +0530 |
commit | ceef7869e0aa122d2959f7a74f88dfba2c8f15df (patch) | |
tree | 3532cfcd98f9a118e81016461f934cd345452993 | |
parent | 5451b9854bf2d6fd0f82211f29c7ff4dcf431267 (diff) | |
download | heat-ceef7869e0aa122d2959f7a74f88dfba2c8f15df.tar.gz |
Don't load all resources for policy check
We only need the resource types for the check. Let's
avoid loading all resources.
Change-Id: Iaf5650b2ae972064292cfe0d17f98b5635c51bad
-rw-r--r-- | heat/common/policy.py | 4 | ||||
-rw-r--r-- | heat/engine/stk_defn.py | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/heat/common/policy.py b/heat/common/policy.py index 7f53b38f7..bfcadbaf4 100644 --- a/heat/common/policy.py +++ b/heat/common/policy.py @@ -188,6 +188,6 @@ class ResourceEnforcer(Enforcer): def enforce_stack(self, stack, scope=None, target=None, is_registered_policy=False): - for res in stack.resources.values(): - self.enforce(stack.context, res.type(), scope=scope, target=target, + for res_type in stack.defn.all_resource_types(): + self.enforce(stack.context, res_type, scope=scope, target=target, is_registered_policy=is_registered_policy) diff --git a/heat/engine/stk_defn.py b/heat/engine/stk_defn.py index eb8e1334c..585a05797 100644 --- a/heat/engine/stk_defn.py +++ b/heat/engine/stk_defn.py @@ -102,6 +102,13 @@ class StackDefinition(object): else: return self.enabled_rsrc_names() + def all_resource_types(self): + """Return the set of types of all resources in the template.""" + if self._resource_defns is None: + self._load_rsrc_defns() + return set(self._resource_defns[res].resource_type + for res in self._resource_defns) + def get_availability_zones(self): """Return the list of Nova availability zones.""" if self._zones is None: |