{
- "created": "2019-09-19T06:31:59.844469",
+ "created": "2019-10-07T06:33:21.040671",
"current_version": "el alto",
"project": "",
"versions": {
"needs_amount": 813
},
"el alto": {
- "created": "2019-09-19T06:31:59.844406",
+ "created": "2019-10-07T06:33:21.040606",
"filters": {},
"filters_amount": 0,
"needs": {
"title_from_content": "",
"type": "req",
"type_name": "Requirement",
- "updated": "dublin",
+ "updated": "el alto",
"validated_by": "",
"validation_mode": "static"
},
"title_from_content": "",
"type": "req",
"type_name": "Requirement",
- "updated": "dublin",
+ "updated": "el alto",
"validated_by": "",
"validation_mode": "static"
},
"title_from_content": "",
"type": "req",
"type_name": "Requirement",
- "updated": "dublin",
+ "updated": "el alto",
"validated_by": "",
"validation_mode": "static"
},
"title_from_content": "",
"type": "req",
"type_name": "Requirement",
- "updated": "dublin",
+ "updated": "el alto",
"validated_by": "",
"validation_mode": "static"
},
"title_from_content": "",
"type": "req",
"type_name": "Requirement",
- "updated": "dublin",
+ "updated": "el alto",
"validated_by": "",
"validation_mode": ""
},
"title_from_content": "",
"type": "req",
"type_name": "Requirement",
- "updated": "dublin",
+ "updated": "el alto",
"validated_by": "",
"validation_mode": "static"
},
"title_from_content": "",
"type": "req",
"type_name": "Requirement",
- "updated": "dublin",
+ "updated": "el alto",
"validated_by": "",
"validation_mode": "in_service"
},
"title_from_content": "",
"type": "req",
"type_name": "Requirement",
- "updated": "",
+ "updated": "el alto",
"validated_by": "",
"validation_mode": "static"
},
"validation_mode": "none"
},
"R-610010": {
- "description": "A VNF's Heat Orchestration Template's Base Module **MAY** declare zero, one,\nor more than one ``OS::Nova::Server`` resource.",
+ "description": "A VNF's Heat Orchestration Template's Base Module **MAY** declare zero, one,\nor more than one ``OS::Nova::Server`` resource. A ``OS::Nova::Server``\n**MAY** be created in the base module or a nested yaml file invoked by the\nbase module.",
"docname": "Chapter5/Heat/ONAP Heat VNF Modularity",
"full_title": "",
"hide_links": "",
"validation_mode": "none"
},
"R-610020": {
- "description": "If a VNF's Heat Orchestration Template's Base Module contains two or more\n``OS::Nova::Server`` resources, the ``OS::Nova::Server`` resources **MAY**\ndefine the same ``{vm-type}`` (as defined in R-01455) or **MAY**\ndefine different ``{vm-type}``.\n\nNote that\n\n- there is no constraint on the number of unique ``{vm-type}`` defined in\n the base module.\n- there is no constraint on the number of ``OS::Nova::Server`` resources\n that define the same ``{vm-type}`` in the base module.",
+ "description": "If a VNF's Heat Orchestration Template's Base Module contains two or more\n``OS::Nova::Server`` resources (created in the base module itself and/or\nin a nested yaml file invoked by the base module), the ``OS::Nova::Server``\nresources **MAY**\ndefine the same ``{vm-type}`` (as defined in R-01455) or **MAY**\ndefine different ``{vm-type}``.\n\nNote that\n\n- there is no constraint on the number of unique ``{vm-type}`` defined in\n the base module.\n- there is no constraint on the number of ``OS::Nova::Server`` resources\n that define the same ``{vm-type}`` in the base module.\n- if an ``OS::Nova::Server`` is created in a nested yaml file invoked by\n the base module, the nested yaml file **MUST NOT** contain more than one\n ``OS::Nova::Server`` resource (as defined in R-17528).",
"docname": "Chapter5/Heat/ONAP Heat VNF Modularity",
"full_title": "",
"hide_links": "",
"validation_mode": "none"
},
"R-610030": {
- "description": "A VNF's Heat Orchestration Template's Incremental Module **MUST**\ndeclare one or more ``OS::Nova::Server`` resources.",
+ "description": "A VNF's Heat Orchestration Template's Incremental Module **MUST**\ndeclare one or more ``OS::Nova::Server`` resources. A ``OS::Nova::Server``\n**MAY** be created in the incremental module or a nested yaml file invoked\nby the incremental module.",
"docname": "Chapter5/Heat/ONAP Heat VNF Modularity",
"full_title": "",
"hide_links": "",
"validation_mode": "static"
},
"R-610040": {
- "description": "If a VNF\u2019s Heat Orchestration Template\u2019s Incremental Module contains two or\nmore ``OS::Nova::Server`` resources, the ``OS::Nova::Server`` resources\n**MAY** define the same ``{vm-type}`` (as defined in R-01455) or **MAY**\ndefine different ``{vm-type}``.\n\nNote that\n\n- there is no constraint on the number of unique ``{vm-type}`` defined in\n the incremental module.\n- there is no constraint on the number of ``OS::Nova::Server`` resources\n that define the same ``{vm-type}`` in the incremental module.",
+ "description": "If a VNF's Heat Orchestration Template's Incremental Module contains two or\nmore ``OS::Nova::Server`` resources, the ``OS::Nova::Server`` resources\n**MAY** define the same ``{vm-type}`` (as defined in R-01455) or **MAY**\ndefine different ``{vm-type}``.\n\nNote that\n\n- there is no constraint on the number of unique ``{vm-type}`` defined in\n the incremental module.\n- there is no constraint on the number of ``OS::Nova::Server`` resources\n that define the same ``{vm-type}`` in the incremental module.\n- if an ``OS::Nova::Server`` is created in a nested yaml file invoked by\n the incremental module, the nested yaml file **MUST NOT** contain more\n than one ``OS::Nova::Server`` resource (as defined in R-17528).",
"docname": "Chapter5/Heat/ONAP Heat VNF Modularity",
"full_title": "",
"hide_links": "",
"validation_mode": "none"
},
"R-610050": {
- "description": "A VNF\u2019s Heat Orchestration Template's ``OS::Nova::Server`` resource unique\n``{vm-type}`` (as defined in R-01455) **MAY** exist in the VNF's\nHeat Orchestration Template's Base Module and/or one or more of the VNF's\nHeat Orchestration Template's Incremental Modules.",
+ "description": "The same ``{vm-type}`` for a VNF's Heat Orchestration Template's\n``OS::Nova::Server`` resource (as defined in R-01455) **MAY** exist in\nthe VNF's Heat Orchestration Template's Base Module (or invoked nested yaml\nfile) and/or one or more of the VNF's Heat Orchestration Template's\nIncremental Modules (or invoked nested yaml file).",
"docname": "Chapter5/Heat/ONAP Heat VNF Modularity",
"full_title": "",
"hide_links": "",
"title_from_content": "",
"type": "req",
"type_name": "Requirement",
- "updated": "dublin",
+ "updated": "el alto",
"validated_by": "",
"validation_mode": "static"
},
"title_from_content": "",
"type": "req",
"type_name": "Requirement",
- "updated": "dublin",
+ "updated": "el alto",
"validated_by": "",
"validation_mode": "static"
},
"title_from_content": "",
"type": "req",
"type_name": "Requirement",
- "updated": "dublin",
+ "updated": "el alto",
"validated_by": "",
"validation_mode": "static"
},
--- /dev/null
+# ============LICENSE_START=======================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+heat_template_version: 2015-05-23
+
+resources:
+
+ int_other_network:
+ type: OS::Neutron::Net
--- /dev/null
+# ============LICENSE_START=======================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+heat_template_version: 2015-05-23
+
+parameters:
+
+ db_int_oam_floating_v6_ip:
+ type: string
--- /dev/null
+# ============LICENSE_START=======================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+heat_template_version: 2015-05-23
+
+resources:
+
+ int_oam_network:
+ type: OS::Neutron::Net
--- /dev/null
+# ============LICENSE_START=======================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+heat_template_version: 2015-05-23
+
+parameters:
+
+ db_int_oam_floating_v6_ip:
+ type: string
--- /dev/null
+# ============LICENSE_START=======================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+heat_template_version: 2015-05-23
+
+parameters:
+
+ db_int_oam_floating_v6_ip:
+ type: string
+
+resources:
+
+ int_oam_network:
+ type: OS::Neutron::Net
--- /dev/null
+# -*- coding: utf8 -*-
+# ============LICENSE_START=======================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+#
+---
+resources:
+ int_oam_netork:
+ type: OS::ContrailV2::VirtualNetwork
--- /dev/null
+# -*- coding: utf8 -*-
+# ============LICENSE_START=======================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+#
+#
+---
+resources:
+ int_oam_netork:
+ type: OS::Neutron::Net
#
---
resources:
- vm_type_1_int_intranet_0_port:
- type: OS::Neutron::Port
- properties:
- network: { get_param: int_intranet_net_name }
-
- vm_type_1_int_vpnnet_0_port:
- type: OS::Neutron::Port
- properties:
- network: { get_param: int_vpnnet_net_id }
-
- vm_type_1_extnet_net_0_port:
- type: OS::Neutron::Port
- properties:
- network: { get_param: extnet_net_name }
-
- vm_type_1_extnet_0_port:
- type: OS::Neutron::Port
- properties:
- network: { get_param: extnet_net_id }
-
- int_oam_netork:
+ int_oam_network:
type: OS::Neutron::Net
properties:
name: { get_param: int_oam_net_name }
-
- vm_type_1_int_oam_1_port:
- type: OS::Neutron::Port
- properties:
- gbgdfjk: { get_resource: int_oam_net }
#
---
resources:
- vm_type_1_int_intranet_0_port:
- type: OS::Neutron::Port
- properties:
- network: { get_param: int_intranet_net_name }
-
- vm_type_1_int_vpnnet_0_port:
- type: OS::Neutron::Port
- properties:
- network: { get_param: int_vpnnet_net_id }
-
- vm_type_1_extnet_net_0_port:
- type: OS::Neutron::Port
- properties:
- network: { get_param: extnet_net_name }
-
- vm_type_1_extnet_0_port:
- type: OS::Neutron::Port
- properties:
- network: { get_param: extnet_net_id }
int_oam_network:
- type: OS::Neutron::Net
- properties:
- name: { get_param: int_oam_net_name }
+ type: OS::Neutron::Net
int_oam_subnet:
- type: OS::Neutron::Subnet
- properties:
- network: { get_resource: int_oam_network }
-
- vm_type_1_int_oam_1_port:
- type: OS::Neutron::Port
+ type: OS::Neutron::Subnet
+ properties:
+ network: { get_resource: int_oam_network }
+
+ int_other_network:
+ type: OS::ContrailV2::VirtualNetwork
+
+ int_other_subnet:
+ type: OS::Neutron::Subnet
properties:
- network: { get_resource: int_oam_net }
+ network: { get_resource: int_other_network }
self.load_env(envpath)
self.heat_processors = self.get_heat_processors()
+ @property
+ def is_heat(self):
+ return "heat_template_version" in self.yml
+
@property
def contrail_resources(self):
"""This attribute is a dict of Contrail resources.
--- /dev/null
+# -*- coding: utf8 -*-
+# ============LICENSE_START=======================================================
+# org.onap.vvp/validation-scripts
+# ===================================================================
+# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# ===================================================================
+#
+# Unless otherwise specified, all software contained herein is licensed
+# under the Apache License, Version 2.0 (the "License");
+# you may not use this software except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+#
+# Unless otherwise specified, all documentation contained herein is licensed
+# under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+# you may not use this documentation except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://creativecommons.org/licenses/by/4.0/
+#
+# Unless required by applicable law or agreed to in writing, documentation
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# ============LICENSE_END============================================
+import re
+from itertools import chain
+
+from tests.helpers import validates
+from tests.structures import Heat
+from tests.test_network_format import NETWORK_RESOURCE_TYPES, RE_INTERNAL_NETWORK_RID
+
+INTERNAL_NETWORK_PARAMETERS = [
+ re.compile(r"int_(.+?)_net_id"),
+ re.compile(r"int_(.+?)_net_name"),
+ re.compile(r".*?_int_(.+?)(?:_v6)?_ips"),
+ re.compile(r".*?_int_(.+?)(?:_v6)?_ip_\d+"),
+ re.compile(r"int_(.+?)(?:_v6)?_subnet_id"),
+ re.compile(r".*_int_(.+?)_floating(?:_v6)?_ip"),
+ re.compile(r".*_int_(.+?)_floating(?:_v6)?_ips"),
+ re.compile(r"(?:.*_)?int_(.+?)_security_group"),
+]
+
+
+def get_network_ids(heat):
+ return set(
+ chain.from_iterable(
+ heat.get_resource_by_type(t)
+ for t in NETWORK_RESOURCE_TYPES
+ )
+ )
+
+
+def get_internal_network_roles(heat_templates):
+ network_ids = chain.from_iterable(get_network_ids(t) for t in heat_templates)
+ matches = (RE_INTERNAL_NETWORK_RID.match(nid) for nid in network_ids)
+ return {m.groupdict().get("network_role", "").lower() for m in matches if m}
+
+
+def first_match(param, patterns):
+ for pattern in patterns:
+ match = pattern.match(param)
+ if match:
+ return match
+ return None
+
+
+@validates("R-35666")
+def test_networks_exist_for_internal_network_params(yaml_files):
+ heat_templates = [t for t in map(Heat, yaml_files) if t.is_heat]
+ network_roles = get_internal_network_roles(heat_templates)
+ errors = []
+ for heat in heat_templates:
+ for param in heat.parameters:
+ match = first_match(param, INTERNAL_NETWORK_PARAMETERS)
+ if not match:
+ continue
+ param_role = match.groups()[0]
+ if param_role not in network_roles:
+ errors.append((
+ "Parameter {} in template {} uses the internal network naming "
+ "convention, but no network with a resource ID of int_{}_network "
+ "was defined in any Heat template. Update the parameter to use "
+ "the naming convention for external networks or ensure the "
+ "internal network is defined in the VNF's Heat templates. Refer "
+ "to Networking section of Heat requirements for full definitions "
+ "of internal vs. external networks."
+ ).format(param, heat.basename, param_role))
+
+ assert not errors, "\n\n".join(errors)
# ============LICENSE_END============================================
#
#
+from itertools import chain
import pytest
import re
from tests import cached_yaml as yaml
+from tests.structures import Heat
-from .helpers import validates
-from .utils.network_roles import property_uses_get_resource
+from tests.helpers import validates
-RE_INTERNAL_NETWORK_RID = re.compile( # match pattern
- r"int_(?P<network_role>.+)_network$"
-)
+RE_INTERNAL_NETWORK_RID = re.compile(r"int_(?P<network_role>.+)_network$")
NETWORK_RESOURCE_TYPES = ["OS::Neutron::Net", "OS::ContrailV2::VirtualNetwork"]
-@validates("R-16968", "R-35666")
+@validates("R-16968")
def test_network_resource_id_format(yaml_file):
- """
- Make sure all network resource ids use the allowed naming
- convention
- """
- RE_INTERNAL_NETWORK_RID = re.compile( # match pattern
- r"int_(?P<network_role>.+)_network$"
+ heat = Heat(yaml_file)
+ network_ids = chain.from_iterable(
+ heat.get_resource_by_type(t) for t in NETWORK_RESOURCE_TYPES
)
-
- with open(yaml_file) as fh:
- yml = yaml.load(fh)
-
- # skip if resources are not defined
- if "resources" not in yml:
- pytest.skip("No resources specified in the heat template")
-
- invalid_networks = []
- for k, v in yml["resources"].items():
- if not has_properties(v):
- continue
- if property_uses_get_resource(v, "network"):
- continue
- if v.get("type") not in NETWORK_RESOURCE_TYPES:
- continue
- match = RE_INTERNAL_NETWORK_RID.match(k)
- if not match:
- invalid_networks.append(k)
-
- assert not set(invalid_networks), (
+ invalid_networks = {
+ r_id for r_id in network_ids if not RE_INTERNAL_NETWORK_RID.match(r_id)
+ }
+ assert not invalid_networks, (
"Heat templates must only create internal networks "
- "and follow format int_{{network-role}}_network"
+ "and their resource IDs must follow the format "
+ "int_{{network-role}}_network. The following network's resource IDs "
+ "have invalid resource ID formats: "
"{}".format(", ".join(invalid_networks))
)
for k, v in yml["resources"].items():
network_prop = v.get("properties", {}).get("network", {}).get("get_resource")
if (
- not has_properties(v) and v.get("type") != "OS::Neutron::Subnet"
+ not has_properties(v)
+ and v.get("type") != "OS::Neutron::Subnet"
and not network_prop
):
continue