Adding operationHistory for get_creds

Change-Id: Ibd8a19ec34e4cbbcf0cd3912ae5cba7b3141fbbc
Signed-off-by: shahithya <shahithya.y@tataelxsi.co.in>
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 @@
 )
 
 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 @@
             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 @@
                 )
                 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
                 )