aboutsummaryrefslogtreecommitdiffstats
path: root/ice_validator/tests/structures.py
diff options
context:
space:
mode:
authorLovett, Trevor <trevor.lovett@att.com>2020-01-16 15:47:59 -0600
committerLovett, Trevor <trevor.lovett@att.com>2020-01-16 15:47:59 -0600
commitded5c74ea07eb1541587de1042444fa6b590ddde (patch)
treef59f044962150b4f75d73f90e1ba59e4ff84c69d /ice_validator/tests/structures.py
parent60d5bfeff163a2155679c9dbece42dc4e085bfd9 (diff)
[VVP] Resources not allowed in 2nd level templates
Cleaned up nesting detection logic Deleted test in Nova Server file as the nesting is no longer related to Nova servers Added check for resources in 2nd level nested files to existing test. Change-Id: I136efb786f67cf4c45fe4da3abaa3fcec024ba50 Issue-ID: VVP-357 Signed-off-by: Lovett, Trevor <trevor.lovett@att.com>
Diffstat (limited to 'ice_validator/tests/structures.py')
-rw-r--r--ice_validator/tests/structures.py33
1 files changed, 31 insertions, 2 deletions
diff --git a/ice_validator/tests/structures.py b/ice_validator/tests/structures.py
index 09dd222..aaed8d1 100644
--- a/ice_validator/tests/structures.py
+++ b/ice_validator/tests/structures.py
@@ -36,8 +36,6 @@
# ============LICENSE_END============================================
#
#
-"""structures
-"""
import collections
import inspect
import os
@@ -732,6 +730,31 @@ class Heat(object):
re.search("(^(%(x)s)_)|(_(%(x)s)_)|(_(%(x)s)$)" % dict(x=part), name)
)
+ def iter_nested_heat(self):
+ """
+ Returns an iterable of tuples (int, heat) where the first parameter is the
+ depth of the nested file and the second item is an instance of Heat
+ """
+
+ def walk_nested(heat, level=1):
+ resources = [Resource(r_id, data) for r_id, data in heat.resources.items()]
+ for resource in resources:
+ if resource.is_nested():
+ nested_path = os.path.join(
+ self.dirname, resource.get_nested_filename()
+ )
+ nested_heat = Heat(nested_path)
+ yield level, nested_heat
+ yield from walk_nested(nested_heat, level + 1)
+
+ yield from walk_nested(self)
+
+ def __str__(self):
+ return "Heat({})".format(self.filepath)
+
+ def __repr__(self):
+ return str(self)
+
class Env(Heat):
"""An Environment file
@@ -832,6 +855,12 @@ class Resource(object):
else:
return {}
+ def __str__(self):
+ return "Resource(id={}, type={})".format(self.resource_id, self.resource_type)
+
+ def __repr__(self):
+ return str(self)
+
def get_all_resources(yaml_files):
"""Return a dict, resource id: resource