X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ice_validator%2Ftests%2Fstructures.py;h=aaed8d10cdb557d83668d09a346b6386d954c784;hb=ded5c74ea07eb1541587de1042444fa6b590ddde;hp=a43524662ad033ffbdcefc4aa50da4b08643d65d;hpb=d856b38ab47ce2405d343fcb7848629892d3c0b7;p=vvp%2Fvalidation-scripts.git diff --git a/ice_validator/tests/structures.py b/ice_validator/tests/structures.py index a435246..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 @@ -563,7 +561,7 @@ class NovaServerProcessor(HeatProcessor): d = dict( flavor=cls.get_flavor(resource), image=cls.get_image(resource), - networks=cls.get_network(resource), + network_role=cls.get_network(resource), ) if all(d.values()): vm_class.update(d) @@ -605,6 +603,10 @@ class Heat(object): self.load_env(envpath) self.heat_processors = self.get_heat_processors() + @property + def is_heat(self): + return "heat_template_version" in self.yml + @property def contrail_resources(self): """This attribute is a dict of Contrail resources. @@ -728,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 @@ -828,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