From: garciadeblas Date: Thu, 15 Aug 2024 08:00:42 +0000 (+0200) Subject: Simplify check of region and resource group in cluster creation X-Git-Tag: release-v16.0-start~3 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F12%2F14512%2F3;p=osm%2FNBI.git Simplify check of region and resource group in cluster creation Change-Id: I4f2b2d434c33f1bebe0388098fdc316d726a8f5a Signed-off-by: garciadeblas --- diff --git a/osm_nbi/k8s_topics.py b/osm_nbi/k8s_topics.py index 2ce01e0..b065c12 100644 --- a/osm_nbi/k8s_topics.py +++ b/osm_nbi/k8s_topics.py @@ -244,26 +244,22 @@ class K8sTopic(BaseTopic): def _create_cluster(self, cls_request, rollback, session, indata, kwargs, headers): # Check whether the region name and resource group have been given - v = "Not_present" - t = "Not_present" - for key, value in indata.items(): - if key == "region_name": - v = "Present" - if key == "resource_group": - t = "Present" + region_given = "region_name" in indata + resource_group_given = "resource_group" in indata # Get the vim_account details vim_account_details = self.db.get_one( "vim_accounts", {"name": cls_request["vim_account"]} ) - if v == "Not_present" and t == "Not_present": + # Check whether the region name and resource group have been given + if not region_given and not resource_group_given: region_name = vim_account_details["config"]["region_name"] resource_group = vim_account_details["config"]["resource_group"] - elif v == "Present" and t == "Not_present": + elif region_given and not resource_group_given: region_name = cls_request["region_name"] resource_group = vim_account_details["config"]["resource_group"] - elif v == "Not_present" and t == "Present": + elif not region_given and resource_group_given: region_name = vim_account_details["config"]["region_name"] resource_group = cls_request["resource_group"] else: