diff options
author | shangxdy <shang.xiaodong@zte.com.cn> | 2016-06-05 01:37:11 +0800 |
---|---|---|
committer | shangxdy <shang.xiaodong@zte.com.cn> | 2016-06-05 01:43:32 +0800 |
commit | a17eab054e89552cfafdad1b0f45d5a613cc2ba6 (patch) | |
tree | f9f73035d7d6b2275c39f1f106cbd8e792298851 /tosca2heat/tosca-parser/toscaparser/tosca_template.py | |
parent | 920592786aabee78752cf35a293a74151b9f3c8b (diff) |
tosco-parser supports importing the other service with
topology template
As a tosca-parser developer;
I want to implement the function of substitution_mapping;
So that must support the import topology template firstly
Change-Id: Ie26aab712e7870e1ec345ad654460bb84014f207
JIRA: PARSER-48
Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
Diffstat (limited to 'tosca2heat/tosca-parser/toscaparser/tosca_template.py')
-rw-r--r-- | tosca2heat/tosca-parser/toscaparser/tosca_template.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tosca2heat/tosca-parser/toscaparser/tosca_template.py b/tosca2heat/tosca-parser/toscaparser/tosca_template.py index ba056da..1bad6e9 100644 --- a/tosca2heat/tosca-parser/toscaparser/tosca_template.py +++ b/tosca2heat/tosca-parser/toscaparser/tosca_template.py @@ -69,6 +69,7 @@ class ToscaTemplate(object): self.input_path = None self.path = None self.tpl = None + self.nested_tosca_template = None if path: self.input_path = path self.path = self._get_path(path) @@ -177,9 +178,14 @@ class ToscaTemplate(object): imports = self._tpl_imports() if imports: - custom_defs = toscaparser.imports.\ + custom_service = toscaparser.imports.\ ImportsLoader(imports, self.path, - type_defs, self.tpl).get_custom_defs() + type_defs, self.tpl) + + nested_topo_tpls = custom_service.get_nested_topo_tpls() + self._handle_nested_topo_tpls(nested_topo_tpls) + + custom_defs = custom_service.get_custom_defs() if not custom_defs: return @@ -191,6 +197,14 @@ class ToscaTemplate(object): custom_defs.update(inner_custom_types) return custom_defs + 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) + def _validate_field(self): version = self._tpl_version() if not version: |