[VVP] Updating vm_type class test to proceed if no cinder 39/98539/2
authorstark, steven <steven.stark@att.com>
Mon, 18 Nov 2019 21:45:47 +0000 (13:45 -0800)
committerstark, steven <steven.stark@att.com>
Mon, 18 Nov 2019 22:30:09 +0000 (14:30 -0800)
Other minor changes
- updating error message to be more clear for vm_type class
- updating test_network_format to handle nested files w/ no resources
- updating ports.py to handle hardcoded str_replace param/values

Issue-ID: VVP-342
Signed-off-by: stark, steven <steven.stark@att.com>
Change-Id: I63fcda582fe25dcedca87e874327b7ea56fe6ef3

ice_validator/tests/structures.py
ice_validator/tests/test_network_format.py
ice_validator/tests/test_vm_class_has_unique_type.py
ice_validator/tests/utils/ports.py

index 887917c..09dd222 100644 (file)
@@ -563,7 +563,7 @@ class NovaServerProcessor(HeatProcessor):
             d = dict(
                 flavor=cls.get_flavor(resource),
                 image=cls.get_image(resource),
-                networks=cls.get_network(resource),
+                network_role=cls.get_network(resource),
             )
             if all(d.values()):
                 vm_class.update(d)
index b291c53..23e46f9 100644 (file)
@@ -79,7 +79,7 @@ def test_network_has_subnet(yaml_file):
 
     networks = []
 
-    for k, v in yml["resources"].items():
+    for k, v in yml.get("resources", {}).items():
         if not has_properties(v) or v.get("type") not in ["OS::Neutron::Net"]:
             continue
         # need to check if contrail networks also require subnet
@@ -87,7 +87,7 @@ def test_network_has_subnet(yaml_file):
         # if v.get("type") not in NETWORK_RESOURCE_TYPES:
         networks.append(k)
 
-    for k, v in yml["resources"].items():
+    for k, v in yml.get("resources", {}).items():
         network_prop = v.get("properties", {}).get("network", {}).get("get_resource")
         if (
             not has_properties(v)
index b158f5b..5938535 100644 (file)
@@ -73,8 +73,8 @@ class VmClassValidator(object):
         self.vm_rids = collections.defaultdict(set)
         self.vm_types = collections.defaultdict(set)
         va_config, self.va_count = CinderVolumeAttachmentProcessor.get_config(resources)
-        if not va_config:
-            pytest.skip("No Cinder Volume Attachment configurations found")
+        if not va_config:
+            pytest.skip("No Cinder Volume Attachment configurations found")
         for rid, resource in resources.items():
             vm_class = NovaServerProcessor.get_vm_class(resource)
             if vm_class:
@@ -98,13 +98,15 @@ class VmClassValidator(object):
         for k, v in self.vm_types.items():
             if len(v) > 1:
                 errors.append(
-                    "vm-type %s has class conflict %s"
+                    "OS::Nova::Server resources with the same vm_type must have identical configurations. "
+                    "The following OS::Nova::Server resources for vm-type %s do not have identical configurations: %s"
                     % (k, ", ".join(str(list(self.vm_classes[c])) for c in v))
                 )
                 classes = list(v)
                 errors.append(
-                    "Differences %s"
-                    % ", ".join([str(key_diff(classes[0], c)) for c in classes[1:]])
+                    "The following attributes are detected differences between "
+                    "OS::Nova::Server's with vm_type %s: %s"
+                    % (k, ", ".join([str(key_diff(classes[0], c)) for c in classes[1:]]))
                 )
         for k, v in self.vm_counts.items():
             if len(v) > 1:
index 1f5f658..d6c3be9 100644 (file)
@@ -160,8 +160,9 @@ def validate_port_parameter(
     If the parameter is present in the resource metadata
     and exemptions are allowed, then the validation will be skipped.
     """
-    parameter = param.get("get_param")
-    if not parameter:
+    if isinstance(param, dict) and "get_param" in param:
+        parameter = param.get("get_param")
+    else:
         return (
             "Unexpected parameter format for {} {} property {}: {}. "
             "Please consult the heat guidelines documentation for details."