"Shahithya Y <shahithya.y@tataelxsi.co.in>",
)
+import copy
import logging
from time import time
import traceback
else:
return await self.check_dummy_operation(op_id, op_params, content)
+ def decrypting_key(self, content):
+ # This deep copy is for to be passed to ODU workflows.
+ cluster_copy = copy.deepcopy(content)
+
+ # decrypting the key
+ self.db.encrypt_decrypt_fields(
+ cluster_copy,
+ "decrypt",
+ ["age_pubkey", "age_privkey"],
+ schema_version="1.11",
+ salt=cluster_copy["_id"],
+ )
+ db_cluster_copy = {
+ "cluster": cluster_copy,
+ }
+ return db_cluster_copy
+
class ClusterLcm(GitOpsLcm):
db_collection = "clusters"
self.logger.info("cluster Create Enter")
db_cluster = content["cluster"]
+ db_cluster_copy = self.decrypting_key(db_cluster)
+
+ # vim account details
+ db_vim = self.db.get_one("vim_accounts", {"name": db_cluster["vim_account"]})
+ db_cluster_copy["vim_account"] = db_vim
+
_, workflow_name = await self.odu.launch_workflow(
- "create_cluster", op_id, op_params, content
+ "create_cluster", op_id, op_params, db_cluster_copy
)
self.logger.info("workflow_name is :{}".format(workflow_name))
# 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, content
+ "create_cluster", op_id, op_params, db_cluster_copy
)
self.logger.info(
f"clean_status is :{clean_status} and clean_msg is :{clean_msg}"
if workflow_status:
resource_status, resource_msg = await self.check_resource_status(
- "create_cluster", op_id, op_params, content
+ "create_cluster", op_id, op_params, db_cluster_copy
)
self.logger.info(
"resource_status is :{} and resource_msg is :{}".format(
db_profile["state"] = db_cluster["state"]
db_profile["resourceState"] = db_cluster["resourceState"]
db_profile["operatingState"] = db_cluster["operatingState"]
+ db_profile["age_pubkey"] = db_cluster["age_pubkey"]
+ db_profile["age_privkey"] = db_profile["age_privkey"]
db_profile = self.update_operation_history(
db_profile, workflow_status, resource_status
)
self.logger.info("cluster register enter")
db_cluster = content["cluster"]
+ db_cluster_copy = self.decrypting_key(db_cluster)
+
_, workflow_name = await self.odu.launch_workflow(
- "register_cluster", op_id, op_params, content
+ "register_cluster", op_id, op_params, db_cluster_copy
)
self.logger.info("workflow_name is :{}".format(workflow_name))
# 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, content
+ "register_cluster", op_id, op_params, db_cluster_copy
)
self.logger.info(
f"clean_status is :{clean_status} and clean_msg is :{clean_msg}"
if workflow_status:
resource_status, resource_msg = await self.check_resource_status(
- "register_cluster", op_id, op_params, content
+ "register_cluster", op_id, op_params, db_cluster_copy
)
self.logger.info(
"resource_status is :{} and resource_msg is :{}".format(
db_cluster, workflow_status, resource_status
)
self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
- self.update_profile_state(db_cluster, workflow_status, resource_status)
return
async def deregister(self, op_id, op_params, content):
self.logger.info("Cluster update Enter")
db_cluster = content["cluster"]
+ db_cluster_copy = self.decrypting_key(db_cluster)
+
+ # vim account details
+ db_vim = self.db.get_one("vim_accounts", {"name": db_cluster["vim_account"]})
+ db_cluster_copy["vim_account"] = db_vim
+
_, workflow_name = await self.odu.launch_workflow(
- "update_cluster", op_id, op_params, content
+ "update_cluster", op_id, op_params, db_cluster_copy
)
workflow_status, workflow_msg = await self.odu.check_workflow_status(
workflow_name
# 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, content
+ "update_cluster", op_id, op_params, db_cluster_copy
)
self.logger.info(
f"clean_status is :{clean_status} and clean_msg is :{clean_msg}"
)
if workflow_status:
resource_status, resource_msg = await self.check_resource_status(
- "update_cluster", op_id, op_params, content
+ "update_cluster", op_id, op_params, db_cluster_copy
)
self.logger.info(
"Resource Status: {} Resource Message: {}".format(