2 # ============LICENSE_START====================================================
3 # org.onap.vvp/validation-scripts
4 # ===================================================================
5 # Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 # ===================================================================
8 # Unless otherwise specified, all software contained herein is licensed
9 # under the Apache License, Version 2.0 (the "License");
10 # you may not use this software except in compliance with the License.
11 # You may obtain a copy of the License at
13 # http://www.apache.org/licenses/LICENSE-2.0
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
23 # Unless otherwise specified, all documentation contained herein is licensed
24 # under the Creative Commons License, Attribution 4.0 Intl. (the "License");
25 # you may not use this documentation except in compliance with the License.
26 # You may obtain a copy of the License at
28 # https://creativecommons.org/licenses/by/4.0/
30 # Unless required by applicable law or agreed to in writing, documentation
31 # distributed under the License is distributed on an "AS IS" BASIS,
32 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33 # See the License for the specific language governing permissions and
34 # limitations under the License.
36 # ============LICENSE_END============================================
47 from .structures import Heat
48 from .helpers import validates
54 def test_nested_parameter_args(yaml_file):
56 If a VNF’s Heat Orchestration Template resource attribute
57 property metadata uses a nested get_param, then the "outer"
58 get_param must take 2 arguments. The first argument must be
59 a parameter of type "comma_delimited_list", and the second
60 argument must be the "inner" get_param whose value must be a
61 parameter of type "number".
65 type: comma_delimited_list
70 type: OS::Nova::Server
72 name: { get_param: [ ex1_vm_names, 0 ] }
74 vnf_id: { get_param: vnf_id }
76 get_param: [ cdl, { get_param: num }]
78 heat = Heat(filepath=yaml_file)
79 if not heat.resources:
80 pytest.skip("No resources found")
81 has_nested_parameters = False
82 bad = collections.defaultdict(list)
83 for rid, r in heat.resources.items():
84 metadata = heat.nested_get(r, "properties", "metadata", default={})
85 for key, value in metadata.items():
86 param = heat.nested_get(value, "get_param")
87 if isinstance(param, list) and len(param) == 2:
88 nested_param = heat.nested_get(param[1], "get_param")
90 has_nested_parameters = True
92 heat.nested_get(heat.parameters, param[0], "type")
96 "%s %s parameter type not %s"
97 % (key, param[0], Heat.type_cdl)
100 heat.nested_get(heat.parameters, nested_param, "type")
104 "%s %s nested parameter type not %s"
105 % (key, nested_param, Heat.type_num)
107 assert not bad, "resource ids with invalid nested parameter arguments\n %s" % (
108 "\n ".join("%s %s" % (k, ", ".join(v)) for k, v in bad.items())
110 if has_nested_parameters is False:
111 pytest.skip("No nested parameters found")