2 # ============LICENSE_START====================================================
3 # org.onap.vvp/validation-scripts
4 # ===================================================================
5 # Copyright © 2017 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.
43 {vm-type}_{vm-type_index}_{network-role}_port_{port-index}:
44 type: OS::Neutron::Port
46 network: { get_param: ...}
47 fixed_ips: [ { "ipaddress": { get_param: ... } } ]
48 binding:vnic_type: direct #only SR-IOV ports, not OVS ports
50 vlan_filter: { get_param: ... }, #all NC ports
51 public_vlans: { get_param: ... }, #all NC ports
52 private_vlans: { get_param: ... },#all NC ports
53 guest_vlans: { get_param: ... }, #SR-IOV Trunk Port only
54 vlan_mirror: { get_param: ... }, #SRIOV Trunk Port
55 # Receiving Mirrored Traffic only
56 ATT_FABRIC_CONFIGURATION_REQUIRED: true #all NC ports
59 port_type: SR-IOV_Trunk #SR-IOV Trunk Port
60 port_type: SR-IOV_Non_Trunk #SR-IOV Non Trunk Port
61 port_type: OVS #OVS Port
62 port_type: SR-IOV_Mirrored_Trunk #SR-IOV Trunk Port
63 # Receiving Mirrored Traffic
71 from .structures import Heat
72 from .helpers import validates
77 def case_mismatch(vm_type, param):
78 """Return True if vm_type matches a portion of param in a case
79 insensitive search, but does not equal that portion;
80 return False otherwise.
81 The "portions" of param are delimited by "_".
83 re_portion = re.compile(
84 "(^(%(x)s)_)|(_(%(x)s)_)|(_(%(x)s)$)" % dict(x=vm_type), re.IGNORECASE
86 found = re_portion.search(param)
88 param_vm_type = [x for x in found.groups()[1::2] if x][0]
89 return param_vm_type != vm_type
94 # pylint: disable=invalid-name
98 def test_vm_type_case(heat_template):
100 A VNF's Heat Orchestration Template's use of ``{vm-type}`` in all Resource
101 property parameter names **MUST** be the same case.
103 heat = Heat(filepath=heat_template)
104 resources = heat.resources
106 pytest.skip("No resources found")
107 bad = collections.defaultdict(list)
108 for rid, resource in resources.items():
109 vm_type = heat.get_vm_type(rid, resource=resource)
111 properties = resource.get("properties")
112 if isinstance(properties, dict):
113 for prop, dic in properties.items():
114 param = heat.nested_get(dic, "get_param")
115 if isinstance(param, list):
117 if isinstance(param, str) and case_mismatch(vm_type, param):
118 bad[(rid, vm_type)].append((prop, param))
120 raise AssertionError(
121 "vm-type/parameter case mis-match %s"
124 "resource: %s vm-type: %s %s"
125 % (k[0], k[1], ", ".join("%s: %s" % i for i in v))
126 for k, v in bad.items()