Fix backward compatibility issue
In the earlier version of TOSCA Parser the call to entry class TOSCATemplate has two arguments, file path and parameters where parameters arg is optional. A new arg has been added in parser as a flag to check if the path is file or not. The old way of calling parser (e.g. ToscaTemplate(path, '')) will not work with it. Should change the constructor signature per patch. Change-Id: Ia543bcaa6967ae68863266faef9689b1e27f0bf7
This commit is contained in:
parent
e0185a3eb4
commit
489686cf5d
@ -57,7 +57,7 @@ def main():
|
||||
|
||||
def parse(path, a_file=True):
|
||||
output = None
|
||||
tosca = ToscaTemplate(path, a_file)
|
||||
tosca = ToscaTemplate(path, None, a_file)
|
||||
version = tosca.version
|
||||
if tosca.version:
|
||||
print ("\nversion:\n" + version)
|
||||
|
@ -402,7 +402,7 @@ class ToscaTemplateTest(TestCase):
|
||||
tosca_tpl = ('https://raw.githubusercontent.com/openstack/'
|
||||
'tosca-parser/master/toscaparser/tests/data/'
|
||||
'tosca_single_instance_wordpress.yaml')
|
||||
tosca = ToscaTemplate(tosca_tpl, False)
|
||||
tosca = ToscaTemplate(tosca_tpl, None, False)
|
||||
self.assertTrue(tosca.topology_template.custom_defs)
|
||||
|
||||
def test_url_template_with_local_abspath_import(self):
|
||||
@ -410,7 +410,8 @@ class ToscaTemplateTest(TestCase):
|
||||
'tosca-parser/master/toscaparser/tests/data/'
|
||||
'tosca_single_instance_wordpress_with_local_abspath_'
|
||||
'import.yaml')
|
||||
err = self.assertRaises(ImportError, ToscaTemplate, tosca_tpl, False)
|
||||
err = self.assertRaises(ImportError, ToscaTemplate, tosca_tpl,
|
||||
None, False)
|
||||
err_msg = (_("Absolute file name /toscaparser/tests/data/custom_types"
|
||||
"/wordpress.yaml cannot be used for a URL-based input "
|
||||
"%(tpl)s template.")
|
||||
@ -421,7 +422,7 @@ class ToscaTemplateTest(TestCase):
|
||||
tosca_tpl = ('https://raw.githubusercontent.com/openstack/'
|
||||
'tosca-parser/master/toscaparser/tests/data/'
|
||||
'tosca_single_instance_wordpress_with_url_import.yaml')
|
||||
tosca = ToscaTemplate(tosca_tpl, False)
|
||||
tosca = ToscaTemplate(tosca_tpl, None, False)
|
||||
self.assertTrue(tosca.topology_template.custom_defs)
|
||||
|
||||
def test_csar_parsing_wordpress(self):
|
||||
@ -433,4 +434,4 @@ class ToscaTemplateTest(TestCase):
|
||||
def test_csar_parsing_elk_url_based(self):
|
||||
csar_archive = ('https://github.com/openstack/tosca-parser/raw/master/'
|
||||
'toscaparser/tests/data/CSAR/csar_elk.zip')
|
||||
self.assertTrue(ToscaTemplate(csar_archive, False))
|
||||
self.assertTrue(ToscaTemplate(csar_archive, None, False))
|
||||
|
@ -48,7 +48,7 @@ class ToscaTemplate(object):
|
||||
VALID_TEMPLATE_VERSIONS = ['tosca_simple_yaml_1_0']
|
||||
|
||||
'''Load the template data.'''
|
||||
def __init__(self, path, a_file=True, parsed_params=None):
|
||||
def __init__(self, path, parsed_params=None, a_file=True):
|
||||
self.a_file = a_file
|
||||
self.path = self._get_path(path)
|
||||
self.tpl = YAML_LOADER(self.path, self.a_file)
|
||||
|
Loading…
x
Reference in New Issue
Block a user