From 4753986cbabc1ddd504a05ebc34cd89377cbb091 Mon Sep 17 00:00:00 2001 From: sreelakshmi-penta Date: Mon, 29 Aug 2016 15:14:41 +0530 Subject: [PATCH] Provided support for TOSCA qualified name. Provided partial fix with the current given fix. Implementation for all deeper hierarchy TOSCA qualified names is in progress and will be delivered in the next patch. Co-Author: manoj6030 Partial-Bug: #1452546 Change-Id: I28ec064f28156ca0e165fee6d216d1f898fe80be --- toscaparser/elements/statefulentitytype.py | 3 ++ toscaparser/tests/test_toscatplvalidation.py | 31 ++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/toscaparser/elements/statefulentitytype.py b/toscaparser/elements/statefulentitytype.py index be9933e..2f221b3 100644 --- a/toscaparser/elements/statefulentitytype.py +++ b/toscaparser/elements/statefulentitytype.py @@ -35,6 +35,9 @@ class StatefulEntityType(EntityType): if UnsupportedType.validate_type(entire_entitytype): self.defs = None else: + if entitytype.startswith(self.TOSCA + ":"): + entitytype = entitytype[(len(self.TOSCA) + 1):] + entire_entitytype = prefix + entitytype if not entitytype.startswith(self.TOSCA): entire_entitytype = prefix + entitytype if entire_entitytype in list(self.TOSCA_DEF.keys()): diff --git a/toscaparser/tests/test_toscatplvalidation.py b/toscaparser/tests/test_toscatplvalidation.py index 15fe007..c8ec052 100644 --- a/toscaparser/tests/test_toscatplvalidation.py +++ b/toscaparser/tests/test_toscatplvalidation.py @@ -1541,3 +1541,34 @@ heat-translator/master/translator/tests/data/custom_types/wordpress.yaml 'unknown field "oss". Refer to the definition ' 'to verify valid values.') self.assertEqual(expectedmessage, err.__str__()) + + def test_qualified_name(self): + tpl_snippet_full_name = ''' + node_templates: + supported_type: + type: tosca.nodes.Compute + ''' + tpl = ( + toscaparser.utils.yamlparser.simple_parse( + tpl_snippet_full_name)) + TopologyTemplate(tpl, None) + + tpl_snippet_short_name = ''' + node_templates: + supported_type: + type: Compute + ''' + tpl = ( + toscaparser.utils.yamlparser.simple_parse( + tpl_snippet_short_name)) + TopologyTemplate(tpl, None) + + tpl_snippet_qualified_name = ''' + node_templates: + supported_type: + type: tosca:Compute + ''' + tpl = ( + toscaparser.utils.yamlparser.simple_parse( + tpl_snippet_qualified_name)) + TopologyTemplate(tpl, None)