self.logger.info(
f"check_create_cluster Operation {op_id}. Params: {op_params}."
)
- # self.logger.debug(f"Content: {content}")
db_cluster = content["cluster"]
cluster_name = db_cluster["git_name"].lower()
cluster_kustomization_name = cluster_name
self.logger.info("the db_cluster is :{}".format(db_cluster))
for profile_type in profiles:
profile_id = db_cluster[profile_type]
- # db_collection = profiles_collection[profile_type]
db_collection = self.profile_collection_mapping[profile_type]
db_profile = self.db.get_one(db_collection, {"_id": profile_id})
op_id = db_profile["operationHistory"][-1].get("op_id")
db_vim = self.db.get_one("vim_accounts", {"name": db_cluster["vim_account"]})
workflow_content["vim_account"] = db_vim
- # TODO: workaround until NBI rejects cluster deletion requests for registered clusters
- # This if clause will be removed
- if db_cluster["created"] == "false":
- return await self.deregister(params, order_id)
-
workflow_res, workflow_name = await self.odu.launch_workflow(
"delete_cluster", op_id, op_params, workflow_content
)
def delete_cluster(self, db_cluster):
# Actually, item_content is equal to db_cluster
- # item_content = self.db.get_one("clusters", {"_id": db_cluster["_id"]})
- # self.logger.debug("item_content is : {}".format(item_content))
-
# detach profiles
update_dict = None
profiles_to_detach = [
profile_ids = db_cluster[profile_type]
profile_ids_copy = deepcopy(profile_ids)
for profile_id in profile_ids_copy:
- # db_collection = profiles_collection[profile_type]
db_collection = self.profile_collection_mapping[profile_type]
db_profile = self.db.get_one(db_collection, {"_id": profile_id})
self.logger.debug("the db_profile is :{}".format(db_profile))
profile_collection = self.profile_collection_mapping[profile_type]
db_profile = self.db.get_one(profile_collection, {"_id": profile_id})
db_profile["profile_type"] = profile_type
- # content["profile"] = db_profile
workflow_content["profile"] = db_profile
workflow_res, workflow_name = await self.odu.launch_workflow(
db_cluster = self.update_operation_history(
db_cluster, op_id, workflow_status, resource_status
)
- # TODO: workaround until NBI rejects cluster deletion requests for registered clusters
- # Setting created flag to true avoids infinite loops when deregistering a cluster
- db_cluster["created"] = "true"
self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
return await self.delete(params, order_id)