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============================================
40 """nested template parameters
46 from .structures import Heat
47 from .helpers import validates
48 from .utils import nested_files
53 def validate_parms(dirname, basename, nested, nested_props, prop_type):
54 """ensure all parms are props
55 return list of errors.
58 for rid, nested_filename in nested.items():
59 nested_filepath = os.path.join(dirname, nested_filename)
60 nested_heat = Heat(filepath=nested_filepath)
61 parms = set(nested_heat.parameters.keys())
62 props = nested_props.get(rid, set())
63 missing = parms - props
66 "%s parameters %s missing as %s"
68 % (nested_filename, list(missing), prop_type, basename, rid)
74 def test_nested_template_parameters(yaml_file):
76 All parameters defined in a VNFs Nested YAML file
77 **MUST** be passed in as properties of the resource calling
80 dirname, basename = os.path.split(yaml_file)
81 heat = Heat(filepath=yaml_file)
82 if not heat.resources:
83 pytest.skip("No resources found")
84 nested_type = nested_files.get_type_nested_files(heat.yml, dirname)
85 nested_resourcegroup = nested_files.get_resourcegroup_nested_files(
88 if not nested_type and not nested_resourcegroup:
89 pytest.skip("No nested files")
92 rid: set(heat.resources[rid].get("properties", {}).keys())
93 for rid in nested_type
95 nested_resourcegroup_props = {
105 for rid in nested_resourcegroup
108 validate_parms(dirname, basename, nested_type, nested_type_props, "properties")
114 nested_resourcegroup,
115 nested_resourcegroup_props,
116 "resource_def.properties",
119 assert not bad, "; ".join(bad)