a708a58c08d502cf400b4a69b6fb450d86b0552a
[vvp/validation-scripts.git] / ice_validator / tests / test_contrail_instance_ip_parameters.py
1 # -*- coding: utf8 -*-
2 # ============LICENSE_START====================================================
3 # org.onap.vvp/validation-scripts
4 # ===================================================================
5 # Copyright © 2019 AT&T Intellectual Property. All rights reserved.
6 # ===================================================================
7 #
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
12 #
13 #             http://www.apache.org/licenses/LICENSE-2.0
14 #
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.
20 #
21 #
22 #
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
27 #
28 #             https://creativecommons.org/licenses/by/4.0/
29 #
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.
35 #
36 # ============LICENSE_END============================================
37 #
38 #
39 import re
40
41 from tests.structures import ContrailV2InstanceIpProcessor
42 from tests.helpers import validates
43 from tests.utils.ports import check_parameter_format
44
45 RE_EXTERNAL_PARAM_IIP = re.compile(  # match pattern
46     r"(?P<vm_type>.+)_(?P<network_role>.+?)(_v6)?_ip_(?P<ip_index>.+)$"
47 )
48
49 RE_EXTERNAL_PARAM_IIPS = re.compile(  # match pattern
50     r"(?P<vm_type>.+)_(?P<network_role>.+?)(_v6)?_ips$"
51 )
52
53 RE_INTERNAL_PARAM_IIP = re.compile(  # match pattern
54     r"(?P<vm_type>.+)_int_(?P<network_role>.+?)(_v6)?_ip_(?P<ip_index>.+)$"
55 )
56
57 RE_INTERNAL_PARAM_IIPS = re.compile(  # match pattern
58     r"(?P<vm_type>.+)_int_(?P<network_role>.+?)(_v6)?_ips$"
59 )
60
61 iip_regx_dict = {
62     "external": {
63         "string": {
64             "readable": "{vm-type}_{network-role}_ip_{ip-index} or {vm-type}_{network-role}_v6_ip_{ip-index}",
65             "machine": RE_EXTERNAL_PARAM_IIP,
66         },
67         "comma_delimited_list": {
68             "readable": "{vm-type}_{network-role}_ips or {vm-type}_{network-role}_v6_ips",
69             "machine": RE_EXTERNAL_PARAM_IIPS,
70         },
71     },
72     "internal": {
73         "string": {
74             "readable": "{vm-type}_int_{network-role}_ip_{ip-index} or {vm-type}_int_{network-role}_v6_ip_{ip-index}",
75             "machine": RE_INTERNAL_PARAM_IIP,
76         },
77         "comma_delimited_list": {
78             "readable": "{vm-type}_int_{network-role}_ips or {vm-type}_int_{network-role}_v6_ips",
79             "machine": RE_INTERNAL_PARAM_IIPS,
80         },
81     },
82     "parameter_to_resource_comparisons": ["vm_type", "network_role"],
83 }
84
85
86 RE_EXTERNAL_PARAM_SID = re.compile(  # match pattern
87     r"(?P<network_role>.+?)(_v6)?_subnet_id$"
88 )
89
90 RE_INTERNAL_PARAM_SID = re.compile(  # match pattern
91     r"int_(?P<network_role>.+?)(_v6)?_subnet_id$"
92 )
93
94 sid_regx_dict = {
95     "external": {
96         "string": {
97             "readable": "{network-role}_subnet_id or {network-role}_v6_subnet_id",
98             "machine": RE_EXTERNAL_PARAM_SID,
99         },
100     },
101     "internal": {
102         "string": {
103             "readable": "int_{network-role}_subnet_id or int_{network-role}_v6_subnet_id",
104             "machine": RE_INTERNAL_PARAM_SID,
105         },
106     },
107     "parameter_to_resource_comparisons": ["network_role"],
108 }
109
110
111 @validates("R-100000", "R-100010", "R-100030", "R-100150", "R-100070")
112 def test_contrail_external_instance_ip_address_parameter(yaml_file):
113     check_parameter_format(yaml_file, iip_regx_dict, "external", ContrailV2InstanceIpProcessor, "instance_ip_address")
114
115
116 @validates("R-100000", "R-100090", "R-100110", "R-100130", "R-100180")
117 def test_contrail_internal_instance_ip_address_parameter(yaml_file):
118     check_parameter_format(yaml_file, iip_regx_dict, "internal", ContrailV2InstanceIpProcessor, "instance_ip_address")
119
120
121 @validates("R-100190", "R-100200", "R-100220")
122 def test_contrail_external_instance_subnet_id_parameter(yaml_file):
123     check_parameter_format(yaml_file, sid_regx_dict, "external", ContrailV2InstanceIpProcessor, "subnet_uuid")
124
125
126 @validates("R-100190", "R-100240", "R-100260")
127 def test_contrail_internal_instance_subnet_id_parameter(yaml_file):
128     check_parameter_format(yaml_file, sid_regx_dict, "internal", ContrailV2InstanceIpProcessor, "subnet_uuid")
129
130
131
132
133