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============================================
38 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
42 {vm-type}_server_{vm-type_index}
46 from .structures import Heat
47 from .structures import ContrailV2InstanceIpProcessor
48 from .helpers import validates
53 def run_test(heat_template, regex_names, network_flavor):
56 heat = Heat(filepath=heat_template)
57 processor = ContrailV2InstanceIpProcessor
58 resource_type = processor.resource_type
59 resources = heat.get_resource_by_type(resource_type=resource_type)
61 pytest.skip("No %s resources found" % resource_type)
63 rid_patterns = processor.get_rid_patterns()
64 for rid, resource in resources.items():
65 flavor = processor.get_network_flavor(resource)
66 if flavor != network_flavor:
68 regex_name = processor.get_rid_match_tuple(rid)[0]
69 if regex_name in regex_names:
72 assert not bad, "%s resource ids %s must match one of %s" % (
75 [v for k, v in rid_patterns.items() if k in regex_names],
79 # pylint: disable=invalid-name
82 @validates("R-53310", "R-46128")
83 def test_contrail_instance_ip_resource_id_external(heat_template):
85 A VNF's Heat Orchestration Template's Resource OS::ContrailV2::InstanceIp
86 that is configuring an IPv4 Address on a port attached to an external
88 Resource ID **MUST** use the naming convention
90 {vm-type}_{vm-type_index}_{network-role}_vmi_{vmi_index}
93 A VNF's Heat Orchestration Template's Resource OS::ContrailV2::InstanceIp
94 that is configuring an IPv6 Address on a port attached to an external
96 Resource ID **MUST** use the naming convention
98 {vm-type}_{vm-type_index}_{network-role}_vmi_{vmi_index}
105 regex_names=("ip", "v6_ip"),
106 network_flavor=ContrailV2InstanceIpProcessor.network_flavor_external,
110 @validates("R-62187", "R-87563")
111 def test_contrail_instance_ip_resource_id_internal(heat_template):
114 {vm-type}_{vm-type_index}_int_{network-role}_vmi_{vmi_index}
116 {vm-type}_{vm-type_index}_int_{network-role}_vmi_{vmi_index}
121 regex_names=("int_ip", "int_v6_ip"),
122 network_flavor=ContrailV2InstanceIpProcessor.network_flavor_internal,
126 @validates("R-20947", "R-88540")
127 def test_contrail_instance_ip_resource_id_subint(heat_template):
130 {vm-type}_{vm-type_index}_subint_{network-role}_vmi_{vmi_index}
132 {vm-type}_{vm-type_index}_subint_{network-role}_vmi_{vmi_index}
137 regex_names=("subint_ip", "subint_v6_ip"),
138 network_flavor=ContrailV2InstanceIpProcessor.network_flavor_subint,