From: Ezhilarasi Date: Wed, 28 Aug 2019 15:07:39 +0000 (+0530) Subject: Sonarfix:Reduce coginitive complexity vmtype util X-Git-Tag: 5.0.0~2 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=vvp%2Fvalidation-scripts.git;a=commitdiff_plain;h=c945b7e0efafee4a46bdf295a22ceff2f0b63e49;hp=84db7f8f65cd0ec77f09cfde365599df9890ce6c Sonarfix:Reduce coginitive complexity vmtype util Change-Id: I4b82df8587b98a142e86031700f8c73e922184d5 Issue-ID: VVP-172 Signed-off-by: Ezhilarasi --- 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