Sonarfix:Reduce coginitive complexity vmtype util
[vvp/validation-scripts.git] / ice_validator / tests / utils / vm_types.py
index c531b67..ae14336 100644 (file)
@@ -52,11 +52,7 @@ def get_vm_types_for_resource(resource):
     """
     if not isinstance(resource, dict):
         return set()
-    if "type" not in resource:
-        return set()
-    if resource["type"] != "OS::Nova::Server":
-        return set()
-    if "properties" not in resource:
+    if not is_nova_server(resource):
         return set()
 
     key_values = ["name", "flavor", "image"]
@@ -85,6 +81,11 @@ def get_vm_types_for_resource(resource):
     return set(vm_types)
 
 
+def is_nova_server(resource):
+
+    return "type" in resource and "properties" in resource and resource.get("type") == "OS::Nova::Server"
+
+
 def get_vm_type_for_nova_server(resource):
     """
     Get the vm_type for a resource