[VVP] Bug fix for test_port_resource_ids
[vvp/validation-scripts.git] / ice_validator / tests / test_port_resource_ids.py
index f53370d..d587743 100644 (file)
@@ -2,7 +2,7 @@
 # ============LICENSE_START=======================================================
 # org.onap.vvp/validation-scripts
 # ===================================================================
-# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+# Copyright © 2019 AT&T Intellectual Property. All rights reserved.
 # ===================================================================
 #
 # Unless otherwise specified, all software contained herein is licensed
@@ -35,7 +35,6 @@
 #
 # ============LICENSE_END============================================
 #
-# ECOMP is a trademark and service mark of AT&T Intellectual Property.
 #
 
 import re
@@ -52,15 +51,15 @@ from .utils.network_roles import (
 from .utils.vm_types import get_vm_type_for_nova_server
 
 
-@validates("R-20453", "R-26351", "R-26506" "R-681859")
-def test_port_resource_ids(heat_template):
+@validates("R-20453", "R-26351", "R-26506", "R-681859")
+def test_port_resource_ids(yaml_file):
     """
     Check that all resource ids for ports follow the right
     naming convention to include the {vm_type} of the
     nova server it is associated to and also contains the
     {network_role} of the network it is associated with
     """
-    with open(heat_template) as fh:
+    with open(yaml_file) as fh:
         yml = yaml.load(fh)
 
     # skip if resources are not defined
@@ -109,14 +108,22 @@ def test_port_resource_ids(heat_template):
 
                 if property_uses_get_resource(v, "network"):
                     continue
+
                 network_role = get_network_role_from_port(port_resource)
                 if not network_role:
+                    invalid_ports.append(
+                        (port_id, "Unable to determine network role for port.")
+                    )
                     continue
                 network_role = network_role.lower()
 
                 network_type = get_network_type_from_port(port_resource)
                 if not network_type:
+                    invalid_ports.append(
+                        (port_id, "Unable to determine network type for port (internal or external).")
+                    )
                     continue
+
                 if network_type == "external":
                     expected_r_id = r"{}_\d+_{}_port_\d+".format(vm_type, network_role)
                 else: