db_vim = self.db.get_one("vim_accounts", {"name": db_cluster["vim_account"]})
workflow_content["vim_account"] = db_vim
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"create_cluster", op_id, op_params, workflow_content
)
- self.logger.info("workflow_name is :{}".format(workflow_name))
+ if not workflow_res:
+ self.logger.error(f"Failed to launch workflow: {workflow_name}")
+ db_cluster["state"] = "FAILED_CREATION"
+ db_cluster["resourceState"] = "ERROR"
+ db_cluster = self.update_operation_history(
+ db_cluster, op_id, workflow_status=False, resource_status=None
+ )
+ self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
+ # Clean items used in the workflow, no matter if the workflow succeeded
+ clean_status, clean_msg = await self.odu.clean_items_workflow(
+ "create_cluster", op_id, op_params, workflow_content
+ )
+ self.logger.info(
+ f"clean_status is :{clean_status} and clean_msg is :{clean_msg}"
+ )
+ return
+ self.logger.info("workflow_name is :{}".format(workflow_name))
workflow_status, workflow_msg = await self.odu.check_workflow_status(
workflow_name
)
if db_cluster["created"] == "false":
return await self.deregister(params, order_id)
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"delete_cluster", op_id, op_params, workflow_content
)
- self.logger.info("workflow_name is :{}".format(workflow_name))
+ if not workflow_res:
+ self.logger.error(f"Failed to launch workflow: {workflow_name}")
+ db_cluster["state"] = "FAILED_DELETION"
+ db_cluster["resourceState"] = "ERROR"
+ db_cluster = self.update_operation_history(
+ db_cluster, op_id, workflow_status=False, resource_status=None
+ )
+ self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
+ # Clean items used in the workflow, no matter if the workflow succeeded
+ clean_status, clean_msg = await self.odu.clean_items_workflow(
+ "delete_cluster", op_id, op_params, workflow_content
+ )
+ self.logger.info(
+ f"clean_status is :{clean_status} and clean_msg is :{clean_msg}"
+ )
+ return
+ self.logger.info("workflow_name is :{}".format(workflow_name))
workflow_status, workflow_msg = await self.odu.check_workflow_status(
workflow_name
)
# content["profile"] = db_profile
workflow_content["profile"] = db_profile
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"attach_profile_to_cluster", op_id, op_params, workflow_content
)
- self.logger.info("workflow_name is :{}".format(workflow_name))
+ if not workflow_res:
+ self.logger.error(f"Failed to launch workflow: {workflow_name}")
+ db_cluster["resourceState"] = "ERROR"
+ self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
+ db_cluster = self.update_operation_history(
+ db_cluster, op_id, workflow_status=False, resource_status=None
+ )
+ return
+ self.logger.info("workflow_name is :{}".format(workflow_name))
workflow_status, workflow_msg = await self.odu.check_workflow_status(
workflow_name
)
# content["profile"] = db_profile
workflow_content["profile"] = db_profile
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"detach_profile_from_cluster", op_id, op_params, workflow_content
)
- self.logger.info("workflow_name is :{}".format(workflow_name))
+ if not workflow_res:
+ self.logger.error(f"Failed to launch workflow: {workflow_name}")
+ db_cluster["resourceState"] = "ERROR"
+ db_cluster = self.update_operation_history(
+ db_cluster, op_id, workflow_status=False, resource_status=None
+ )
+ self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
+ return
+ self.logger.info("workflow_name is :{}".format(workflow_name))
workflow_status, workflow_msg = await self.odu.check_workflow_status(
workflow_name
)
"cluster": self.decrypted_copy(db_cluster),
}
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"register_cluster", op_id, op_params, workflow_content
)
- self.logger.info("workflow_name is :{}".format(workflow_name))
+ if not workflow_res:
+ self.logger.error(f"Failed to launch workflow: {workflow_name}")
+ db_cluster["state"] = "FAILED_CREATION"
+ db_cluster["resourceState"] = "ERROR"
+ db_cluster = self.update_operation_history(
+ db_cluster, op_id, workflow_status=False, resource_status=None
+ )
+ self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
+ # Clean items used in the workflow, no matter if the workflow succeeded
+ clean_status, clean_msg = await self.odu.clean_items_workflow(
+ "register_cluster", op_id, op_params, workflow_content
+ )
+ self.logger.info(
+ f"clean_status is :{clean_status} and clean_msg is :{clean_msg}"
+ )
+ return
+ self.logger.info("workflow_name is :{}".format(workflow_name))
workflow_status, workflow_msg = await self.odu.check_workflow_status(
workflow_name
)
"cluster": self.decrypted_copy(db_cluster),
}
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"deregister_cluster", op_id, op_params, workflow_content
)
- self.logger.info("workflow_name is :{}".format(workflow_name))
+ if not workflow_res:
+ self.logger.error(f"Failed to launch workflow: {workflow_name}")
+ db_cluster["state"] = "FAILED_DELETION"
+ db_cluster["resourceState"] = "ERROR"
+ db_cluster = self.update_operation_history(
+ db_cluster, op_id, workflow_status=False, resource_status=None
+ )
+ self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
+ # Clean items used in the workflow, no matter if the workflow succeeded
+ clean_status, clean_msg = await self.odu.clean_items_workflow(
+ "deregister_cluster", op_id, op_params, workflow_content
+ )
+ self.logger.info(
+ f"clean_status is :{clean_status} and clean_msg is :{clean_msg}"
+ )
+ return
+ self.logger.info("workflow_name is :{}".format(workflow_name))
workflow_status, workflow_msg = await self.odu.check_workflow_status(
workflow_name
)
db_vim = self.db.get_one("vim_accounts", {"name": db_cluster["vim_account"]})
workflow_content["vim_account"] = db_vim
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"update_cluster", op_id, op_params, workflow_content
)
+ if not workflow_res:
+ self.logger.error(f"Failed to launch workflow: {workflow_name}")
+ db_cluster["resourceState"] = "ERROR"
+ db_cluster = self.update_operation_history(
+ db_cluster, op_id, workflow_status=False, resource_status=None
+ )
+ self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
+ # Clean items used in the workflow, no matter if the workflow succeeded
+ clean_status, clean_msg = await self.odu.clean_items_workflow(
+ "update_cluster", op_id, op_params, workflow_content
+ )
+ self.logger.info(
+ f"clean_status is :{clean_status} and clean_msg is :{clean_msg}"
+ )
+ return
+ self.logger.info("workflow_name is :{}".format(workflow_name))
workflow_status, workflow_msg = await self.odu.check_workflow_status(
workflow_name
)
salt=vim_id,
)
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"create_cloud_credentials", op_id, op_params, db_content
)
salt=vim_id,
)
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"update_cloud_credentials", op_id, op_params, db_content
)
workflow_status, workflow_msg = await self.odu.check_workflow_status(
op_params = params
db_content = self.db.get_one("vim_accounts", {"_id": vim_id})
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"delete_cloud_credentials", op_id, op_params, db_content
)
workflow_status, workflow_msg = await self.odu.check_workflow_status(
op_params = self.get_operation_params(content, op_id)
self.db.set_one("k8sapp", {"_id": content["_id"]}, content)
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"create_profile", op_id, op_params, content
)
self.logger.info("workflow_name is :{}".format(workflow_name))
content = self.db.get_one("k8sapp", {"_id": profile_id})
op_params = self.get_operation_params(content, op_id)
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"delete_profile", op_id, op_params, content
)
self.logger.info("workflow_name is :{}".format(workflow_name))
op_params = self.get_operation_params(content, op_id)
self.db.set_one("k8sresource", {"_id": content["_id"]}, content)
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"create_profile", op_id, op_params, content
)
self.logger.info("workflow_name is :{}".format(workflow_name))
content = self.db.get_one("k8sresource", {"_id": profile_id})
op_params = self.get_operation_params(content, op_id)
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"delete_profile", op_id, op_params, content
)
self.logger.info("workflow_name is :{}".format(workflow_name))
op_params = self.get_operation_params(content, op_id)
self.db.set_one("k8sinfra_controller", {"_id": content["_id"]}, content)
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"create_profile", op_id, op_params, content
)
self.logger.info("workflow_name is :{}".format(workflow_name))
content = self.db.get_one("k8sinfra_controller", {"_id": profile_id})
op_params = self.get_operation_params(content, op_id)
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"delete_profile", op_id, op_params, content
)
self.logger.info("workflow_name is :{}".format(workflow_name))
op_params = self.get_operation_params(content, op_id)
self.db.set_one("k8sinfra_config", {"_id": content["_id"]}, content)
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"create_profile", op_id, op_params, content
)
self.logger.info("workflow_name is :{}".format(workflow_name))
content = self.db.get_one("k8sinfra_config", {"_id": profile_id})
op_params = self.get_operation_params(content, op_id)
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"delete_profile", op_id, op_params, content
)
self.logger.info("workflow_name is :{}".format(workflow_name))
db_content = self.db.get_one(self.db_collection, {"_id": oka_id})
op_params = self.get_operation_params(db_content, op_id)
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"create_oka", op_id, op_params, db_content
)
db_content = self.db.get_one(self.db_collection, {"_id": oka_id})
op_params = self.get_operation_params(db_content, op_id)
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"update_oka", op_id, op_params, db_content
)
workflow_status = await self.check_workflow_and_update_db(
db_content = self.db.get_one(self.db_collection, {"_id": oka_id})
op_params = self.get_operation_params(db_content, op_id)
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"delete_oka", op_id, op_params, db_content
)
workflow_status = await self.check_workflow_and_update_db(
op_params.append(ksu_params)
# A single workflow is launched for all KSUs
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"create_ksus", op_id, op_params, db_content
)
# Update workflow status in all KSUs
] = f"{oka_type}/{db_oka['git_name']}/templates"
op_params.append(ksu_params)
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"update_ksus", op_id, op_params, db_content
)
ksu_params["profile"]["age_pubkey"] = db_profile.get("age_pubkey", "")
op_params.append(ksu_params)
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"delete_ksus", op_id, op_params, db_content
)
self.initialize_operation(ksus_id, op_id)
db_content = self.db.get_one(self.db_collection, {"_id": ksus_id})
op_params = self.get_operation_params(db_content, op_id)
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"clone_ksus", op_id, op_params, db_content
)
self.initialize_operation(ksus_id, op_id)
db_content = self.db.get_one(self.db_collection, {"_id": ksus_id})
op_params = self.get_operation_params(db_content, op_id)
- _, workflow_name = await self.odu.launch_workflow(
+ workflow_res, workflow_name = await self.odu.launch_workflow(
"move_ksus", op_id, op_params, db_content
)