Update profile state and agekeys during cluster registration 57/15157/1
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Thu, 3 Apr 2025 22:19:13 +0000 (00:19 +0200)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Thu, 3 Apr 2025 22:19:28 +0000 (00:19 +0200)
Change-Id: I612f4fa22d2008f740f5d60c3692d8094d7a2842
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osm_lcm/k8s.py

index cd22a99..21df2b1 100644 (file)
@@ -353,6 +353,8 @@ class ClusterLcm(GitOpsLcm):
 
     async def create(self, params, order_id):
         self.logger.info("cluster Create Enter")
+        workflow_status = None
+        resource_status = None
 
         # To get the cluster and op ids
         cluster_id = params["cluster_id"]
@@ -980,6 +982,8 @@ class ClusterLcm(GitOpsLcm):
 
     async def register(self, params, order_id):
         self.logger.info("cluster register enter")
+        workflow_status = None
+        resource_status = None
 
         # To get the cluster and op ids
         cluster_id = params["cluster_id"]
@@ -995,8 +999,9 @@ class ClusterLcm(GitOpsLcm):
         op_params = self.get_operation_params(db_cluster, op_id)
 
         # To copy the cluster content and decrypting fields to use in workflows
+        db_cluster_copy = self.decrypted_copy(db_cluster)
         workflow_content = {
-            "cluster": self.decrypted_copy(db_cluster),
+            "cluster": db_cluster_copy,
         }
 
         workflow_res, workflow_name = await self.odu.launch_workflow(
@@ -1069,6 +1074,10 @@ class ClusterLcm(GitOpsLcm):
         db_cluster["current_operation"] = None
         self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster)
 
+        # Update default profile agekeys and state
+        self.update_default_profile_agekeys(db_cluster_copy)
+        self.update_profile_state(db_cluster, workflow_status, resource_status)
+
         db_register = self.db.get_one("k8sclusters", {"name": db_cluster["name"]})
         db_register["credentials"] = db_cluster["credentials"]
         self.db.set_one("k8sclusters", {"_id": db_register["_id"]}, db_register)