From 59a65caaf5b197e2b41c9a41655494b87dc65ae5 Mon Sep 17 00:00:00 2001 From: Mathieu Velten Date: Fri, 11 Aug 2017 12:52:54 +0000 Subject: [PATCH] Revert "Fix: nested resources cannot be given out" This reverts commit 3c53dc729fb71798c7e6a6b602b368cbb4b67991. Change-Id: I0230daa7b860f7f35ef5cd7be6e1d1a0d4547912 --- translator/common/utils.py | 9 +-------- translator/hot/syntax/hot_template.py | 9 ++++----- translator/hot/tosca_translator.py | 5 ++--- translator/tests/test_tosca_hot_translation.py | 18 ++++-------------- 4 files changed, 11 insertions(+), 30 deletions(-) diff --git a/translator/common/utils.py b/translator/common/utils.py index 85af60a5..874c8ec9 100644 --- a/translator/common/utils.py +++ b/translator/common/utils.py @@ -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] = \ diff --git a/translator/hot/syntax/hot_template.py b/translator/hot/syntax/hot_template.py index f279997e..7fae0220 100644 --- a/translator/hot/syntax/hot_template.py +++ b/translator/hot/syntax/hot_template.py @@ -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 diff --git a/translator/hot/tosca_translator.py b/translator/hot/tosca_translator.py index a637a8ca..b9d4c775 100644 --- a/translator/hot/tosca_translator.py +++ b/translator/hot/tosca_translator.py @@ -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, diff --git a/translator/tests/test_tosca_hot_translation.py b/translator/tests/test_tosca_hot_translation.py index 95df72a7..f67c86c6 100644 --- a/translator/tests/test_tosca_hot_translation.py +++ b/translator/tests/test_tosca_hot_translation.py @@ -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, ' : ' + 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(