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============================================
42 {vm-type}_server_{vm-type_index}
46 from .structures import Heat
47 from .structures import ContrailV2VirtualMachineInterfaceProcessor
48 from .helpers import validates
53 def run_test(heat_template, regex_name, network_flavor):
56 heat = Heat(filepath=heat_template)
57 heat_object_class = ContrailV2VirtualMachineInterfaceProcessor
58 resource_type = heat_object_class.resource_type
59 resources = heat.get_resource_by_type(resource_type=resource_type)
61 pytest.skip("No %s resources found" % resource_type)
63 heat_object = heat_object_class()
64 rid_pattern = heat_object.get_rid_patterns()[regex_name]
65 for rid, resource in resources.items():
66 flavor = heat_object.get_network_flavor(resource)
67 if flavor != network_flavor:
69 name = heat_object.get_rid_match_tuple(rid)[0]
70 if name == regex_name:
73 assert not bad, "%s resource ids %s must match %s" % (
80 # pylint: disable=invalid-name
84 def test_contrail_instance_ip_resource_id_external(yaml_file):
86 A VNF's Heat Orchestration Template's Resource
87 OS::ContrailV2::VirtualMachineInterface that is attaching to an
89 Resource ID **MUST** use the naming convention
91 {vm-type}_{vm-type_index}_{network-role}_vmi_{vmi_index}
95 regex_name="vmi_external",
96 network_flavor=ContrailV2VirtualMachineInterfaceProcessor.network_flavor_external,
100 @validates("R-50468")
101 def test_contrail_instance_ip_resource_id_internal(yaml_file):
103 A VNF's Heat Orchestration Template's Resource
104 OS::ContrailV2::VirtualMachineInterface that is attaching to an
106 Resource ID **MUST** use the naming convention
108 {vm-type}_{vm-type_index}_int_{network-role}_vmi_{vmi_index}
112 regex_name="vmi_internal",
113 network_flavor=ContrailV2VirtualMachineInterfaceProcessor.network_flavor_internal,
117 @validates("R-54458")
118 def test_contrail_instance_ip_resource_id_subint(yaml_file):
120 A VNF's Heat Orchestration Template's Resource
121 OS::ContrailV2::VirtualMachineInterface that is attaching to an
122 sub-interface network
123 Resource ID **MUST** use the naming convention
125 {vm-type}_{vm-type_index}_subint_{network-role}_vmi_{vmi_index}
129 regex_name="vmi_subint",
130 network_flavor=ContrailV2VirtualMachineInterfaceProcessor.network_flavor_subint,