2 # ============LICENSE_START====================================================
3 # org.onap.vvp/validation-scripts
4 # ===================================================================
5 # Copyright © 2019 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============================================
39 from tests.parametrizers import get_nested_files
40 from tests.utils.network_roles import get_network_type_from_port
41 from .structures import Heat
42 from .helpers import validates, load_yaml, get_base_template_from_yaml_files
46 def test_neutron_port_internal_network_v2(yaml_files):
47 base_path = get_base_template_from_yaml_files(yaml_files)
48 nested_template_paths = get_nested_files(yaml_files)
50 for yaml_file in yaml_files:
51 if yaml_file == base_path or yaml_file in nested_template_paths:
52 continue # Only applies to incremental modules
53 heat = Heat(filepath=yaml_file)
56 for r_id, p in heat.neutron_port_resources.items()
57 if get_network_type_from_port(p) == "internal"
59 for r_id, port in internal_ports.items():
60 props = port.get("properties") or {}
61 network_value = props.get("network") or {}
62 if not isinstance(network_value, dict):
64 if "get_param" not in network_value:
65 continue # Not connecting to network outside the template
66 param = network_value.get("get_param")
67 base_heat = load_yaml(base_path)
68 base_outputs = base_heat.get("outputs") or {}
69 if not param.endswith("_net_id"):
72 "Internal network {} is attached to port {}, but the "
73 "network must be attached via UUID of the network not "
74 "the name (ex: int_{{network-role}}_net_id)."
77 if param not in base_outputs:
80 "Internal network {} is attached to port {}, but network "
81 "is not defined as an output in the base module ({})."
82 ).format(param, r_id, base_path)
85 assert not errors, " ".join(errors)