[VVP] Enforce R-35666 by ensuring a network exists for int_ parameters 98/96698/1
authorLovett, Trevor <trevor.lovett@att.com>
Mon, 7 Oct 2019 21:06:17 +0000 (16:06 -0500)
committerLovett, Trevor (tl2972) <tl2972@att.com>
Mon, 7 Oct 2019 21:12:35 +0000 (16:12 -0500)
Implements a basic sanity check that if parameters match the internal
network naming convention, then we ensure the network itself was
defined in a heat template.

Change-Id: I37c84e2c62745a51a90dd60f0aaeb213d784f003
Issue-ID: VVP-327
Signed-off-by: Lovett, Trevor (tl2972) <trevor.lovett@att.com>
13 files changed:
ice_validator/heat_requirements.json
ice_validator/tests/fixtures/test_internal_networks/fail/base.yaml [new file with mode: 0644]
ice_validator/tests/fixtures/test_internal_networks/fail/module.yaml [new file with mode: 0644]
ice_validator/tests/fixtures/test_internal_networks/pass/multi_file/base.yaml [new file with mode: 0644]
ice_validator/tests/fixtures/test_internal_networks/pass/multi_file/module.yaml [new file with mode: 0644]
ice_validator/tests/fixtures/test_internal_networks/pass/single_file/base.yaml [new file with mode: 0644]
ice_validator/tests/fixtures/test_network_format/fail/contrail/invalid_contrail_network_name.yaml [new file with mode: 0644]
ice_validator/tests/fixtures/test_network_format/fail/neutron/invalid_neutron_net_name.yaml [new file with mode: 0644]
ice_validator/tests/fixtures/test_network_format/fail/subnet/missing_subnet.yaml [moved from ice_validator/tests/fixtures/test_network_format/fail/invalid_naming_used_for_network.yaml with 72% similarity]
ice_validator/tests/fixtures/test_network_format/pass/valid_heat_template.yaml
ice_validator/tests/structures.py
ice_validator/tests/test_internal_networks.py [new file with mode: 0644]
ice_validator/tests/test_network_format.py

index 3918702..e028715 100644 (file)
@@ -1,5 +1,5 @@
 {
-    "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"
                 }, 
diff --git a/ice_validator/tests/fixtures/test_internal_networks/fail/base.yaml b/ice_validator/tests/fixtures/test_internal_networks/fail/base.yaml
new file mode 100644 (file)
index 0000000..d73dea3
--- /dev/null
@@ -0,0 +1,41 @@
+# ============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
diff --git a/ice_validator/tests/fixtures/test_internal_networks/fail/module.yaml b/ice_validator/tests/fixtures/test_internal_networks/fail/module.yaml
new file mode 100644 (file)
index 0000000..1644859
--- /dev/null
@@ -0,0 +1,41 @@
+# ============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
diff --git a/ice_validator/tests/fixtures/test_internal_networks/pass/multi_file/base.yaml b/ice_validator/tests/fixtures/test_internal_networks/pass/multi_file/base.yaml
new file mode 100644 (file)
index 0000000..a35b7d5
--- /dev/null
@@ -0,0 +1,41 @@
+# ============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
diff --git a/ice_validator/tests/fixtures/test_internal_networks/pass/multi_file/module.yaml b/ice_validator/tests/fixtures/test_internal_networks/pass/multi_file/module.yaml
new file mode 100644 (file)
index 0000000..1644859
--- /dev/null
@@ -0,0 +1,41 @@
+# ============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
diff --git a/ice_validator/tests/fixtures/test_internal_networks/pass/single_file/base.yaml b/ice_validator/tests/fixtures/test_internal_networks/pass/single_file/base.yaml
new file mode 100644 (file)
index 0000000..45f6896
--- /dev/null
@@ -0,0 +1,46 @@
+# ============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
diff --git a/ice_validator/tests/fixtures/test_network_format/fail/contrail/invalid_contrail_network_name.yaml b/ice_validator/tests/fixtures/test_network_format/fail/contrail/invalid_contrail_network_name.yaml
new file mode 100644 (file)
index 0000000..d89564b
--- /dev/null
@@ -0,0 +1,42 @@
+# -*- 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
diff --git a/ice_validator/tests/fixtures/test_network_format/fail/neutron/invalid_neutron_net_name.yaml b/ice_validator/tests/fixtures/test_network_format/fail/neutron/invalid_neutron_net_name.yaml
new file mode 100644 (file)
index 0000000..d573ad8
--- /dev/null
@@ -0,0 +1,42 @@
+# -*- 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 }
index 8755077..3035deb 100644 (file)
 #
 ---
 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 }
index a435246..887917c 100644 (file)
@@ -605,6 +605,10 @@ class Heat(object):
             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.
diff --git a/ice_validator/tests/test_internal_networks.py b/ice_validator/tests/test_internal_networks.py
new file mode 100644 (file)
index 0000000..92cad9c
--- /dev/null
@@ -0,0 +1,101 @@
+# -*- 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)
index de8115d..98fcd37 100644 (file)
 # ============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))
     )
 
@@ -114,7 +95,8 @@ def test_network_has_subnet(yaml_file):
     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