From 7be4cd79e87b7b97cc78715326361240bd204419 Mon Sep 17 00:00:00 2001 From: Niraj Date: Tue, 17 Mar 2020 12:52:24 +0530 Subject: [PATCH] Add support for list data type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In ETSI tosca definition, node type “tosca.nodes.nfv.VNF” has property “vnfm_info” that is defined as of type list. Definition given in etsi_nfv_sol001_vnfd_types.yaml: tosca.nodes.nfv.VNF: properties: vnfm_info: type: list required: true Example: tosca.nodes.nfv.VNF: properties: vnfm_info: [vnfm1, vnfm2] Added translation support for list data type. Change-Id: I02a4ba46da588ef7c1ac36a15d7cd537187e3ecc --- translator/hot/tests/test_translate_inputs.py | 31 +++++++++++++++++++ translator/hot/translate_inputs.py | 3 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/translator/hot/tests/test_translate_inputs.py b/translator/hot/tests/test_translate_inputs.py index 2b302ab8..ddb2f9ce 100644 --- a/translator/hot/tests/test_translate_inputs.py +++ b/translator/hot/tests/test_translate_inputs.py @@ -349,3 +349,34 @@ class ToscaTemplateInputValidationTest(TestCase): ('default', '18.0.1')])}] self._translate_input_test(tpl_snippet, input_params, expectedmessage, expected_hot_params) + + def test_valid_input_vnfm_info(self): + tpl_snippet = ''' + inputs: + vnfm_info: + type: list + entry_schema: + type: string + constraints: [ valid_values: [ Tacker ] ] + default: [ Tacker ] + ''' + + input_params = {'vnfm_info': ['Tacker']} + expected_msg = _("vnfm_info type should be list") + self._translate_input_test(tpl_snippet, input_params, expected_msg) + + def test_invalid_input_vnfm_info(self): + tpl_snippet = ''' + inputs: + vnfm_info: + type: list + entry_schema: + type: string + constraints: [ valid_values: [ Tacker ] ] + default: [ Tacker ] + ''' + parameter = 'Tacker' + input_params = {'vnfm_info': parameter} + expected_msg = _('"%s" is not a list.') + self._translate_input_test(tpl_snippet, input_params, + expected_msg % parameter) diff --git a/translator/hot/translate_inputs.py b/translator/hot/translate_inputs.py index 6d677d1a..1943b0a5 100644 --- a/translator/hot/translate_inputs.py +++ b/translator/hot/translate_inputs.py @@ -53,7 +53,8 @@ TOSCA_TO_HOT_INPUT_TYPES = {'string': 'string', 'scalar-unit.size': 'number', 'version': 'string', 'null': 'string', - 'PortDef': 'number'} + 'PortDef': 'number', + 'list': 'list'} log = logging.getLogger('heat-translator')