Bug 2362 fixed:Operational-status is not getting updated when healing is triggered
[osm/LCM.git] / osm_lcm / lcm_utils.py
index 579a2a5..af460d2 100644 (file)
@@ -40,10 +40,6 @@ class LcmException(Exception):
     pass
 
 
-class LcmExceptionNoMgmtIP(LcmException):
-    pass
-
-
 class LcmExceptionExit(LcmException):
     pass
 
@@ -196,6 +192,9 @@ def vld_to_ro_ip_profile(source_data):
             "dhcp_count": source_data["dhcp-params"].get("count")
             if source_data.get("dhcp-params")
             else None,
+            "ipv6_address_mode": source_data["ipv6-address-mode"]
+            if "ipv6-address-mode" in source_data
+            else None,
         }
 
 
@@ -237,7 +236,7 @@ class LcmBase:
         Returns:
             hex digest  (str): The hash of the charm file
         """
-        filehash = hashlib.md5()
+        filehash = hashlib.sha256()
         with open(zipped_file, mode="rb") as file:
             contents = file.read()
             filehash.update(contents)
@@ -449,6 +448,26 @@ class LcmBase:
             self.logger.error(f"{error} occured while getting the charm name")
             raise LcmException(error)
 
+    def get_vca_info(self, ee_item, db_nsr, get_charm_name: bool):
+        vca_name = charm_name = vca_type = None
+        if ee_item.get("juju"):
+            vca_name = ee_item["juju"].get("charm")
+            if get_charm_name:
+                charm_name = self.find_charm_name(db_nsr, str(vca_name))
+            vca_type = (
+                "lxc_proxy_charm"
+                if ee_item["juju"].get("charm") is not None
+                else "native_charm"
+            )
+            if ee_item["juju"].get("cloud") == "k8s":
+                vca_type = "k8s_proxy_charm"
+            elif ee_item["juju"].get("proxy") is False:
+                vca_type = "native_charm"
+        elif ee_item.get("helm-chart"):
+            vca_name = ee_item["helm-chart"]
+            vca_type = "helm-v3"
+        return vca_name, charm_name, vca_type
+
 
 class TaskRegistry(LcmBase):
     """
@@ -568,17 +587,19 @@ class TaskRegistry(LcmBase):
         """
         Cancel all active tasks of a concrete ns, nsi, vim_account, sdn identified for _id. If op_id is supplied only
         this is cancelled, and the same with task_name
+        :return: cancelled task to be awaited if needed
         """
         if not self.task_registry[topic].get(_id):
             return
         for op_id in reversed(self.task_registry[topic][_id]):
             if target_op_id and target_op_id != op_id:
                 continue
-            for task_name, task in self.task_registry[topic][_id][op_id].items():
+            for task_name, task in list(self.task_registry[topic][_id][op_id].items()):
                 if target_task_name and target_task_name != task_name:
                     continue
                 # result =
                 task.cancel()
+                yield task
                 # if result:
                 #     self.logger.debug("{} _id={} order_id={} task={} cancelled".format(topic, _id, op_id, task_name))