summaryrefslogtreecommitdiffstats
path: root/tosca2heat/tosca-parser/toscaparser/imports.py
diff options
context:
space:
mode:
Diffstat (limited to 'tosca2heat/tosca-parser/toscaparser/imports.py')
-rw-r--r--tosca2heat/tosca-parser/toscaparser/imports.py25
1 files changed, 18 insertions, 7 deletions
diff --git a/tosca2heat/tosca-parser/toscaparser/imports.py b/tosca2heat/tosca-parser/toscaparser/imports.py
index 5149382..62748bd 100644
--- a/tosca2heat/tosca-parser/toscaparser/imports.py
+++ b/tosca2heat/tosca-parser/toscaparser/imports.py
@@ -36,6 +36,7 @@ class ImportsLoader(object):
tpl=None):
self.importslist = importslist
self.custom_defs = {}
+ self.nested_topo_tpls = []
if not path and not tpl:
msg = _('Input tosca template is not provided.')
log.warning(msg)
@@ -55,6 +56,9 @@ class ImportsLoader(object):
def get_custom_defs(self):
return self.custom_defs
+ def get_nested_topo_tpls(self):
+ return self.nested_topo_tpls
+
def _validate_and_load_imports(self):
imports_names = set()
@@ -76,8 +80,8 @@ class ImportsLoader(object):
ValidationError(message=msg))
imports_names.add(import_name)
- custom_type = self._load_import_template(import_name,
- import_uri)
+ full_file_name, custom_type = self._load_import_template(
+ import_name, import_uri)
namespace_prefix = None
if isinstance(import_uri, dict):
namespace_prefix = import_uri.get(
@@ -86,13 +90,15 @@ class ImportsLoader(object):
TypeValidation(custom_type, import_def)
self._update_custom_def(custom_type, namespace_prefix)
else: # old style of imports
- custom_type = self._load_import_template(None,
- import_def)
+ full_file_name, custom_type = self._load_import_template(
+ None, import_def)
if custom_type:
TypeValidation(
custom_type, import_def)
self._update_custom_def(custom_type, None)
+ self._update_nested_topo_tpls(full_file_name, custom_type)
+
def _update_custom_def(self, custom_type, namespace_prefix):
outer_custom_types = {}
for type_def in self.type_definition_list:
@@ -112,6 +118,11 @@ class ImportsLoader(object):
else:
self.custom_defs.update(outer_custom_types)
+ def _update_nested_topo_tpls(self, full_file_name, custom_tpl):
+ if full_file_name and custom_tpl:
+ topo_tpl = {full_file_name: custom_tpl}
+ self.nested_topo_tpls.append(topo_tpl)
+
def _validate_import_keys(self, import_name, import_uri_def):
if self.FILE not in import_uri_def.keys():
log.warning(_('Missing keyname "file" in import "%(name)s".')
@@ -170,7 +181,7 @@ class ImportsLoader(object):
return
if toscaparser.utils.urlutils.UrlUtils.validate_url(file_name):
- return YAML_LOADER(file_name, False)
+ return file_name, YAML_LOADER(file_name, False)
elif not repository:
import_template = None
if self.path:
@@ -234,7 +245,7 @@ class ImportsLoader(object):
ImportError(_('Import "%s" is not valid.') %
import_uri_def))
return
- return YAML_LOADER(import_template, a_file)
+ return import_template, YAML_LOADER(import_template, a_file)
if short_import_notation:
log.error(_('Import "%(name)s" is not valid.') % import_uri_def)
@@ -261,7 +272,7 @@ class ImportsLoader(object):
return
if toscaparser.utils.urlutils.UrlUtils.validate_url(full_url):
- return YAML_LOADER(full_url, False)
+ return full_url, YAML_LOADER(full_url, False)
else:
msg = (_('repository url "%(n_uri)s" is not valid in import '
'definition "%(tpl)s".')