Feature-9904: Enhancing NG-UI to enable Juju operational view dashboard 33/10233/5
authorPriyadharshini G S <priyadharshini.g@tataelxsi.co.in>
Thu, 28 Jan 2021 06:55:40 +0000 (06:55 +0000)
committerPriyadharshini G S <priyadharshini.g@tataelxsi.co.in>
Tue, 9 Feb 2021 04:56:21 +0000 (04:56 +0000)
Implemented functions to receive vcaStatus update message from kafka
and update nsr record in mongo.
Addressed review comments

Change-Id: I54f526c74fd27328c88721002d41bd85a182f9eb
Signed-off-by: ksaikiranr <saikiran.k@tataelxsi.co.in>
Signed-off-by: Priyadharshini G S <priyadharshini.g@tataelxsi.co.in>
osm_lcm/lcm.py
osm_lcm/ns.py

index eaf2558..a3fa609 100644 (file)
@@ -350,6 +350,13 @@ class Lcm:
                 task = asyncio.ensure_future(self.ns.terminate(nsr_id, nslcmop_id))
                 self.lcm_tasks.register("ns", nsr_id, nslcmop_id, "ns_terminate", task)
                 return
+            elif command == "vca_status_refresh":
+                nslcmop = params
+                nslcmop_id = nslcmop["_id"]
+                nsr_id = nslcmop["nsInstanceId"]
+                task = asyncio.ensure_future(self.ns.vca_status_refresh(nsr_id, nslcmop_id))
+                self.lcm_tasks.register("ns", nsr_id, nslcmop_id, "ns_vca_status_refresh", task)
+                return
             elif command == "action":
                 # self.logger.debug("Update NS {}".format(nsr_id))
                 nslcmop = params
index 2a0e8b4..cbfb868 100644 (file)
@@ -197,7 +197,6 @@ class NsLcm(LcmBase):
 
         # self.logger.debug('_on_update_n2vc_db(table={}, filter={}, path={}, updated_data={}'
         #                   .format(table, filter, path, updated_data))
-
         try:
 
             nsr_id = filter.get('_id')
@@ -3644,6 +3643,24 @@ class NsLcm(LcmBase):
         except Exception as e:
             return 'FAIL', 'Error executing action {}: {}'.format(primitive, e)
 
+    async def vca_status_refresh(self, nsr_id, nslcmop_id):
+        """
+        Updating the vca_status with latest juju information in nsrs record
+        :param: nsr_id: Id of the nsr
+        :param: nslcmop_id: Id of the nslcmop
+        :return: None
+        """
+
+        self.logger.debug("Task ns={} action={} Enter".format(nsr_id, nslcmop_id))
+        db_nsr = self.db.get_one("nsrs", {"_id": nsr_id})
+
+        for vca_index, _ in enumerate(db_nsr['_admin']['deployed']['VCA']):
+            table, filter, path = "nsrs", {"_id": nsr_id}, "_admin.deployed.VCA.{}.".format(vca_index)
+            await self._on_update_n2vc_db(table, filter, path, {})
+
+        self.logger.debug("Task ns={} action={} Exit".format(nsr_id, nslcmop_id))
+        self.lcm_tasks.remove("ns", nsr_id, nslcmop_id, "ns_vca_status_refresh")
+
     async def action(self, nsr_id, nslcmop_id):
 
         # Try to lock HA task here