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: