diff options
Diffstat (limited to 'tosca2heat/tosca-parser/toscaparser/tosca_template.py')
-rw-r--r-- | tosca2heat/tosca-parser/toscaparser/tosca_template.py | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/tosca2heat/tosca-parser/toscaparser/tosca_template.py b/tosca2heat/tosca-parser/toscaparser/tosca_template.py index 1bad6e9..8753a2c 100644 --- a/tosca2heat/tosca-parser/toscaparser/tosca_template.py +++ b/tosca2heat/tosca-parser/toscaparser/tosca_template.py @@ -23,6 +23,7 @@ from toscaparser.elements.entity_type import update_definitions from toscaparser.extensions.exttools import ExtTools import toscaparser.imports from toscaparser.prereq.csar import CSAR +from toscaparser.repositories import Repository from toscaparser.topology_template import TopologyTemplate from toscaparser.tpl_relationship_graph import ToscaGraph from toscaparser.utils.gettextutils import _ @@ -69,7 +70,7 @@ class ToscaTemplate(object): self.input_path = None self.path = None self.tpl = None - self.nested_tosca_template = None + self.nested_tosca_template = [] if path: self.input_path = path self.path = self._get_path(path) @@ -95,6 +96,7 @@ class ToscaTemplate(object): self.relationship_types = self._tpl_relationship_types() self.description = self._tpl_description() self.topology_template = self._topology_template() + self.repositories = self._tpl_repositories() if self.topology_template.tpl: self.inputs = self._inputs() self.relationship_templates = self._relationship_templates() @@ -134,6 +136,15 @@ class ToscaTemplate(object): def _tpl_imports(self): return self.tpl.get(IMPORTS) + def _tpl_repositories(self): + repositories = self.tpl.get(REPOSITORIES) + reposit = [] + if repositories: + for name, val in repositories.items(): + reposits = Repository(name, val) + reposit.append(reposits) + return reposit + def _tpl_relationship_types(self): return self._get_custom_types(RELATIONSHIP_TYPES) @@ -199,11 +210,13 @@ class ToscaTemplate(object): def _handle_nested_topo_tpls(self, nested_topo_tpls): for tpl in nested_topo_tpls: - if tpl.get(TOPOLOGY_TEMPLATE): - nested_tosca_template = ToscaTemplate( - path=self.path, parsed_params=self.parsed_params, - yaml_dict_tpl=nested_topo_tpls) - self.nested_tosca_template.apend(nested_tosca_template) + filename, tosca_tpl = list(tpl.items())[0] + if tosca_tpl.get(TOPOLOGY_TEMPLATE): + nested_template = ToscaTemplate( + path=filename, parsed_params=self.parsed_params, + yaml_dict_tpl=tosca_tpl) + if nested_template.topology_template.substitution_mappings: + self.nested_tosca_template.apend(nested_template) def _validate_field(self): version = self._tpl_version() |