Merge "Fix Tosca Parser returns an exception in the output when run on a node type template"

This commit is contained in:
Jenkins
2016-01-12 16:43:02 +00:00
committed by Gerrit Code Review
3 changed files with 21 additions and 4 deletions

View File

@@ -78,8 +78,8 @@ class ImportsLoader(object):
if isinstance(import_uri, dict):
namespace_prefix = import_uri.get(
self.NAMESPACE_PREFIX)
self._update_custom_def(custom_type, namespace_prefix)
if custom_type:
self._update_custom_def(custom_type, namespace_prefix)
else: # old style of imports
custom_type = self._load_import_template(None,
import_def)
@@ -183,6 +183,7 @@ class ImportsLoader(object):
else:
a_file = True
main_a_file = os.path.isfile(self.path)
if main_a_file:
if os.path.isfile(file_name):
import_template = file_name
@@ -192,6 +193,22 @@ class ImportsLoader(object):
file_name)
if os.path.isfile(full_path):
import_template = full_path
else:
file_path = file_name.rpartition("/")
dir_path = os.path.dirname(os.path.abspath(
self.path))
if file_path[0] != '' and dir_path.endswith(
file_path[0]):
import_template = dir_path + "/" +\
file_path[2]
if not os.path.isfile(import_template):
msg = (_('"%(import_template)s" is'
'not a valid file')
% {'import_template':
import_template})
log.error(msg)
ExceptionCollector.appendException
(ValueError(msg))
else: # template is pre-parsed
if os.path.isabs(file_name):
import_template = file_name

View File

@@ -108,8 +108,8 @@ class CSARPrereqTest(TestCase):
"data/CSAR/csar_wordpress_invalid_import_path.zip")
csar = CSAR(path)
error = self.assertRaises(ImportError, csar.validate)
self.assertEqual(_('Import "Definitions/wordpress.yaml" is not '
'valid.'), str(error))
self.assertEqual(_('Import "Invalid_import_path/wordpress.yaml" is'
' not valid.'), str(error))
self.assertTrue(csar.temp_dir is None or
not os.path.exists(csar.temp_dir))