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============================================
38 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
41 """nested template parameters
47 from .structures import Heat
48 from .helpers import validates
49 from .utils import nested_files
54 def validate_parms(dirname, basename, nested, nested_props, prop_type):
55 """ensure all parms are props
56 return list of errors.
59 for rid, nested_filename in nested.items():
60 nested_filepath = os.path.join(dirname, nested_filename)
61 nested_heat = Heat(filepath=nested_filepath)
62 parms = set(nested_heat.parameters.keys())
63 props = nested_props.get(rid, set())
64 missing = parms - props
67 "%s parameters %s missing as %s"
69 % (nested_filename, list(missing), prop_type, basename, rid)
75 def test_nested_template_parameters(heat_template):
77 All parameters defined in a VNFs Nested YAML file
78 **MUST** be passed in as properties of the resource calling
81 dirname, basename = os.path.split(heat_template)
82 heat = Heat(filepath=heat_template)
83 if not heat.resources:
84 pytest.skip("No resources found")
85 nested_type = nested_files.get_type_nested_files(heat.yml, dirname)
86 nested_resourcegroup = nested_files.get_resourcegroup_nested_files(
89 if not nested_type and not nested_resourcegroup:
90 pytest.skip("No nested files")
93 rid: set(heat.resources[rid].get("properties", {}).keys())
94 for rid in nested_type
96 nested_resourcegroup_props = {
106 for rid in nested_resourcegroup
109 validate_parms(dirname, basename, nested_type, nested_type_props, "properties")
115 nested_resourcegroup,
116 nested_resourcegroup_props,
117 "resource_def.properties",
120 assert not bad, "; ".join(bad)