Bug 2312 Fix for manual healing with invalid vdu id 22/14722/3
authorjegan <jegan.s@tataelxsi.co.in>
Mon, 13 Nov 2023 05:01:53 +0000 (05:01 +0000)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Tue, 11 Feb 2025 15:05:03 +0000 (16:05 +0100)
Change-Id: I8d9388da3a883889e90d7cd6a2a6a741338c6f6b
Signed-off-by: jegan <jegan.s@tataelxsi.co.in>
osm_nbi/instance_topics.py

index 4ed706b..b176801 100644 (file)
@@ -1549,7 +1549,24 @@ class NsLcmOpTopic(BaseTopic):
             )
 
     def _check_heal_ns_operation(self, indata, nsr):
-        return
+        try:
+            for data in indata.get("healVnfData"):
+                vnf_id = data.get("vnfInstanceId")
+                vnf = self.db.get_one("vnfrs", {"_id": vnf_id})
+                vnfd_member_vnf_index = vnf.get("member-vnf-index-ref")
+                vnfd = self._get_vnfd_from_vnf_member_index(
+                    vnfd_member_vnf_index, nsr["_id"]
+                )
+                if data.get("additionalParams"):
+                    vdu_id = data["additionalParams"].get("vdu")
+                    if vdu_id:
+                        for index in range(len(vdu_id)):
+                            vdu = vdu_id[index].get("vdu-id")
+                            self._check_valid_vdu(vnfd, vdu)
+        except (DbException, AttributeError, IndexError, KeyError, ValueError) as e:
+            raise type(e)(
+                "Ns healing request could not be processed with error: {}.".format(e)
+            )
 
     def _check_instantiate_ns_operation(self, indata, nsr, session):
         vnf_member_index_to_vnfd = {}  # map between vnf_member_index to vnf descriptor.