[VVP] updating OS::Neutron::Port parameter tests
[vvp/validation-scripts.git] / ice_validator / tests / test_fixed_ips_include_vm_type_network_role.py
1 # -*- coding: utf8 -*-
2 # ============LICENSE_START=======================================================
3 # org.onap.vvp/validation-scripts
4 # ===================================================================
5 # Copyright © 2017 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
40 import re
41
42 from .helpers import validates
43 from .utils.ports import check_ip_format
44
45
46 RE_EXTERNAL_PARAM_FIP = re.compile(  # match pattern
47     r"(?P<vm_type>.+)_(?P<network_role>.+[^(v6)])(_v6)?_ip_(?P<ip_index>.+)$"
48 )
49
50 RE_EXTERNAL_PARAM_FIPS = re.compile(  # match pattern
51     r"(?P<vm_type>.+)_(?P<network_role>.+[^(v6)])(_v6)?_ips$"
52 )
53
54 RE_INTERNAL_PARAM_FIP = re.compile(  # match pattern
55     r"(?P<vm_type>.+)_int_(?P<network_role>.+[^(v6)])(_v6)?_ip_(?P<ip_index>.+)$"
56 )
57
58 RE_INTERNAL_PARAM_FIPS = re.compile(  # match pattern
59     r"(?P<vm_type>.+)_int_(?P<network_role>.+[^(v6)])(_v6)?_ips$"
60 )
61
62 fip_regx_dict = {
63     "external": {
64         "string": {
65             "readable": "{vm-type}_{network-role}_ip_{ip-index} or {vm-type}_{network-role}_v6_ip_{ip-index}",
66             "machine": RE_EXTERNAL_PARAM_FIP,
67         },
68         "comma_delimited_list": {
69             "readable": "{vm-type}_{network-role}_ips or {vm-type}_{network-role}_v6_ips",
70             "machine": RE_EXTERNAL_PARAM_FIPS,
71         },
72     },
73     "internal": {
74         "string": {
75             "readable": "{vm-type}_int_{network-role}_ip_{ip-index} or {vm-type}_int_{network-role}_v6_ip_{ip-index}",
76             "machine": RE_INTERNAL_PARAM_FIP,
77         },
78         "comma_delimited_list": {
79             "readable": "{vm-type}_int_{network-role}_ips or {vm-type}_int_{network-role}_v6_ips",
80             "machine": RE_INTERNAL_PARAM_FIPS,
81         },
82     },
83     "parameter_to_resource_comparisons": ["vm_type", "network_role"],
84 }
85
86
87 @validates("R-40971", "R-35735", "R-23503", "R-71577", "R-04697", "R-34037")
88 def test_external_fip_format(yaml_file):
89     check_ip_format(yaml_file, fip_regx_dict, "external", "fixed_ips", "ip_address")
90
91
92 @validates("R-27818", "R-29765", "R-85235", "R-78380", "R-34037")
93 def test_internal_fip_format(yaml_file):
94     check_ip_format(yaml_file, fip_regx_dict, "internal", "fixed_ips", "ip_address")