From c3a6c49e784c5e7c8043a4c93b55bced672e5ca7 Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Thu, 15 Aug 2024 10:00:42 +0200 Subject: [PATCH] Simplify check of region and resource group in cluster creation Change-Id: I4f2b2d434c33f1bebe0388098fdc316d726a8f5a Signed-off-by: garciadeblas --- osm_nbi/k8s_topics.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) 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: -- 2.25.1