Merge "Revert "Fix: nested resources cannot be given out""

This commit is contained in:
Jenkins 2017-08-11 13:05:01 +00:00 committed by Gerrit Code Review
commit 3aeadae8cf
4 changed files with 11 additions and 30 deletions

View File

@ -216,8 +216,7 @@ class YamlUtils(object):
class TranslationUtils(object):
@staticmethod
def compare_tosca_translation_with_hot(tosca_file, hot_files, params,
nested_resources=False):
def compare_tosca_translation_with_hot(tosca_file, hot_files, params):
'''Verify tosca translation against the given hot specification.
inputs:
@ -248,12 +247,6 @@ class TranslationUtils(object):
basename = os.path.basename(hot_files[0])
output_hot_templates = translate.translate_to_yaml_files_dict(basename)
if nested_resources:
basename = os.path.basename(hot_files[0])
output_hot_templates =\
translate.translate_to_yaml_files_dict(basename, True)
output_dict = {}
for output_hot_template_name in output_hot_templates:
output_dict[output_hot_template_name] = \

View File

@ -46,8 +46,7 @@ class HotTemplate(object):
return yaml.nodes.MappingNode(u'tag:yaml.org,2002:map', nodes)
def output_to_yaml_files_dict(self, base_filename,
hot_template_version=LATEST,
embed_substack_templates=False):
hot_template_version=LATEST):
yaml_files_dict = {}
base_filename, ext = os.path.splitext(base_filename)
@ -56,9 +55,9 @@ class HotTemplate(object):
yaml_files_dict.update(
resource.extract_substack_templates(base_filename,
hot_template_version))
if not embed_substack_templates:
yaml_files_dict[base_filename + ext] = \
self.output_to_yaml(hot_template_version, False)
yaml_files_dict[base_filename + ext] = \
self.output_to_yaml(hot_template_version, False)
return yaml_files_dict

View File

@ -71,8 +71,7 @@ class TOSCATranslator(object):
return yaml_files["output.yaml"]
def translate_to_yaml_files_dict(self, base_filename,
nested_resources=False):
def translate_to_yaml_files_dict(self, base_filename):
"""Translate to HOT YAML
This method produces a translated output containing main and
@ -83,7 +82,7 @@ class TOSCATranslator(object):
self._translate_to_hot_yaml()
return self.hot_template.output_to_yaml_files_dict(
base_filename,
self.node_translator.hot_template_version, nested_resources)
self.node_translator.hot_template_version)
def _translate_inputs(self):
translator = TranslateInputs(self.tosca.inputs, self.parsed_params,

View File

@ -26,15 +26,14 @@ from translator.tests.base import TestCase
class ToscaHotTranslationTest(TestCase):
def _test_successful_translation(self, tosca_file, hot_files, params=None,
nested_resources=False):
def _test_successful_translation(self, tosca_file, hot_files, params=None):
if not params:
params = {}
if not isinstance(hot_files, list):
hot_files = [hot_files]
diff =\
TranslationUtils.compare_tosca_translation_with_hot(
tosca_file, hot_files, params, nested_resources)
diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
hot_files,
params)
self.assertEqual({}, diff, '<difference> : ' +
json.dumps(diff, indent=4, separators=(', ', ': ')))
@ -528,15 +527,6 @@ class ToscaHotTranslationTest(TestCase):
params = {}
self._test_successful_translation(tosca_file, hot_files, params)
def test_hot_translate_scaling_nested_plate(self):
tosca_file = '../tests/data/autoscaling/tosca_autoscaling.yaml'
hot_files = [
'../tests/data/hot_output/autoscaling/asg_res.yaml'
]
params = {}
self._test_successful_translation(tosca_file, hot_files, params,
nested_resources=True)
def test_translate_unsupported_tosca_type(self):
tosca_file = '../tests/data/test_tosca_unsupported_type.yaml'
tosca_tpl = os.path.normpath(os.path.join(