aboutsummaryrefslogtreecommitdiffstats
path: root/ice_validator/tests
diff options
context:
space:
mode:
authorEzhilarasi <ezhrajam@in.ibm.com>2019-08-28 20:37:39 +0530
committerEzhilarasi R <ezhrajam@in.ibm.com>2019-08-30 07:39:32 +0000
commitc945b7e0efafee4a46bdf295a22ceff2f0b63e49 (patch)
tree85a2fb5cbfb602be43e593b25983087a14991241 /ice_validator/tests
parent84db7f8f65cd0ec77f09cfde365599df9890ce6c (diff)
Sonarfix:Reduce coginitive complexity vmtype util
Change-Id: I4b82df8587b98a142e86031700f8c73e922184d5 Issue-ID: VVP-172 Signed-off-by: Ezhilarasi <ezhrajam@in.ibm.com>
Diffstat (limited to 'ice_validator/tests')
-rw-r--r--ice_validator/tests/utils/vm_types.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/ice_validator/tests/utils/vm_types.py b/ice_validator/tests/utils/vm_types.py
index c531b67..ae14336 100644
--- a/ice_validator/tests/utils/vm_types.py
+++ b/ice_validator/tests/utils/vm_types.py
@@ -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