Add transaction subsystem definition in the use case of
[parser.git] / tosca2heat / tosca-parser / toscaparser / imports.py
index 62748bd..86c10f0 100644 (file)
@@ -14,6 +14,7 @@ import logging
 import os
 
 from toscaparser.common.exception import ExceptionCollector
+from toscaparser.common.exception import InvalidPropertyValueError
 from toscaparser.common.exception import MissingRequiredFieldError
 from toscaparser.common.exception import UnknownFieldError
 from toscaparser.common.exception import ValidationError
@@ -161,12 +162,17 @@ class ImportsLoader(object):
         | URL      | URL    | OK                           |
         +----------+--------+------------------------------+
         """
-
         short_import_notation = False
         if isinstance(import_uri_def, dict):
             self._validate_import_keys(import_name, import_uri_def)
             file_name = import_uri_def.get(self.FILE)
             repository = import_uri_def.get(self.REPOSITORY)
+            repos = self.repositories.keys()
+            if repository is not None:
+                if repository not in repos:
+                    ExceptionCollector.appendException(
+                        InvalidPropertyValueError(
+                            what=_('Repository is not found in "%s"') % repos))
         else:
             file_name = import_uri_def
             repository = None
@@ -178,7 +184,7 @@ class ImportsLoader(object):
                    % {'import_name': import_name})
             log.error(msg)
             ExceptionCollector.appendException(ValidationError(message=msg))
-            return
+            return None, None
 
         if toscaparser.utils.urlutils.UrlUtils.validate_url(file_name):
             return file_name, YAML_LOADER(file_name, False)
@@ -193,7 +199,7 @@ class ImportsLoader(object):
                                % {'name': file_name, 'template': self.path})
                         log.error(msg)
                         ExceptionCollector.appendException(ImportError(msg))
-                        return
+                        return None, None
                     import_template = toscaparser.utils.urlutils.UrlUtils.\
                         join_url(self.path, file_name)
                     a_file = False
@@ -236,7 +242,7 @@ class ImportsLoader(object):
                            % {'name': file_name})
                     log.error(msg)
                     ExceptionCollector.appendException(ImportError(msg))
-                    return
+                    return None, None
 
             if not import_template:
                 log.error(_('Import "%(name)s" is not valid.') %
@@ -244,14 +250,14 @@ class ImportsLoader(object):
                 ExceptionCollector.appendException(
                     ImportError(_('Import "%s" is not valid.') %
                                 import_uri_def))
-                return
+                return None, None
             return import_template, YAML_LOADER(import_template, a_file)
 
         if short_import_notation:
             log.error(_('Import "%(name)s" is not valid.') % import_uri_def)
             ExceptionCollector.appendException(
                 ImportError(_('Import "%s" is not valid.') % import_uri_def))
-            return
+            return None, None
 
         full_url = ""
         if repository:
@@ -269,7 +275,7 @@ class ImportsLoader(object):
                        % {'n_uri': repository, 'tpl': import_name})
                 log.error(msg)
                 ExceptionCollector.appendException(ImportError(msg))
-                return
+                return None, None
 
         if toscaparser.utils.urlutils.UrlUtils.validate_url(full_url):
             return full_url, YAML_LOADER(full_url, False)