From d940c65cfc70f7757d9e5b807eb2b3f1dbd8453b Mon Sep 17 00:00:00 2001 From: yshah Date: Thu, 17 Oct 2024 06:11:12 +0000 Subject: [PATCH] Adding operationHistory for get_creds Change-Id: Ibd8a19ec34e4cbbcf0cd3912ae5cba7b3141fbbc Signed-off-by: shahithya --- osm_lcm/k8s.py | 11 +++++++++-- osm_lcm/lcm.py | 5 +++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/osm_lcm/k8s.py b/osm_lcm/k8s.py index 6074155..572b902 100644 --- a/osm_lcm/k8s.py +++ b/osm_lcm/k8s.py @@ -19,6 +19,7 @@ __author__ = ( ) import logging +from time import time from osm_lcm.lcm_utils import LcmBase from copy import deepcopy from osm_lcm import odu_workflows @@ -471,12 +472,18 @@ class ClusterLcm(LcmBase): self.db.del_one("clusters", {"_id": db_cluster["_id"]}) return - async def get_creds(self, db_cluster): + async def get_creds(self, op_id, db_cluster): self.logger.info("Cluster get creds Enter") result, cluster_creds = await self.odu.get_cluster_credentials(db_cluster) if result: db_cluster["credentials"] = cluster_creds - self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster) + op_len = 0 + for operations in db_cluster["operationHistory"]: + if operations["op_id"] == op_id: + db_cluster["operationHistory"][op_len]["result"] = result + db_cluster["operationHistory"][op_len]["endDate"] = time() + op_len += 1 + self.db.set_one("clusters", {"_id": db_cluster["_id"]}, db_cluster) return async def update(self, op_id, op_params, content): diff --git a/osm_lcm/lcm.py b/osm_lcm/lcm.py index a138565..f4c8f32 100644 --- a/osm_lcm/lcm.py +++ b/osm_lcm/lcm.py @@ -850,9 +850,10 @@ class Lcm: ) return elif command == "get_creds": - cluster_id = params["_id"] + cluster_id = params["cluster_id"] + op_id = params["operation_id"] db_cluster = self.db.get_one("clusters", {"_id": cluster_id}) - task = asyncio.ensure_future(self.cluster.get_creds(db_cluster)) + task = asyncio.ensure_future(self.cluster.get_creds(op_id, db_cluster)) self.lcm_tasks.register( "cluster", cluster_id, cluster_id, "cluster_get_credentials", task ) -- 2.25.1