parsing IM configuration execution-environ-list
[osm/LCM.git] / osm_lcm / vim_sdn.py
index 6b1a338..4cd5a6c 100644 (file)
@@ -1042,7 +1042,7 @@ class K8sClusterLcm(LcmBase):
                                            detailed_status=detailed_status_HA)
             except DbException as e:
                 self.logger.error(logging_text + "Cannot update database: {}".format(e))
-            self.lcm_tasks.remove("k8sclusters", k8scluster_id, order_id)
+            self.lcm_tasks.remove("k8scluster", k8scluster_id, order_id)
 
     async def delete(self, k8scluster_content, order_id):
 
@@ -1074,12 +1074,16 @@ class K8sClusterLcm(LcmBase):
             uninstall_sw = deep_get(db_k8scluster, ("_admin", "helm-chart", "created"))
             cluster_removed = True
             if k8s_hc_id:
+                step = "Removing helm-chart '{}'".format(k8s_hc_id)
                 uninstall_sw = uninstall_sw or False
                 cluster_removed = await self.helm_k8scluster.reset(cluster_uuid=k8s_hc_id, uninstall_sw=uninstall_sw)
+                db_k8scluster_update["_admin.helm-chart.id"] = None
 
             if k8s_jb_id:
+                step = "Removing juju-bundle '{}'".format(k8s_jb_id)
                 uninstall_sw = uninstall_sw or False
                 cluster_removed = await self.juju_k8scluster.reset(cluster_uuid=k8s_jb_id, uninstall_sw=uninstall_sw)
+                db_k8scluster_update["_admin.juju-bundle.id"] = None
 
             # Try to remove from cluster_inserted to clean old versions
             if k8s_hc_id and cluster_removed:
@@ -1093,14 +1097,14 @@ class K8sClusterLcm(LcmBase):
                         self.update_db_2("k8srepos", k8srepo["_id"], {"_admin.cluster-inserted": cluster_list})
                     except Exception as e:
                         self.logger.error("{}: {}".format(step, e))
-                self.db.del_one("k8sclusters", {"_id": k8scluster_id})
-            else:
-                raise LcmException("An error happened during the reset of the k8s cluster '{}'".format(k8scluster_id))
-            # if not cluster_removed:
-            #     raise Exception("K8scluster was not properly removed")
+            self.db.del_one("k8sclusters", {"_id": k8scluster_id})
+            db_k8scluster_update = {}
 
         except Exception as e:
-            self.logger.critical(logging_text + "Exit Exception {}".format(e), exc_info=True)
+            if isinstance(e, (LcmException, DbException, K8sException, N2VCException)):
+                self.logger.error(logging_text + "Exit Exception {}".format(e))
+            else:
+                self.logger.critical(logging_text + "Exit Exception {}".format(e), exc_info=True)
             exc = e
         finally:
             if exc and db_k8scluster:
@@ -1119,7 +1123,7 @@ class K8sClusterLcm(LcmBase):
                                            detailed_status=detailed_status_HA)
             except DbException as e:
                 self.logger.error(logging_text + "Cannot update database: {}".format(e))
-            self.lcm_tasks.remove("k8sclusters", k8scluster_id, order_id)
+            self.lcm_tasks.remove("k8scluster", k8scluster_id, order_id)
 
 
 class K8sRepoLcm(LcmBase):
@@ -1213,6 +1217,7 @@ class K8sRepoLcm(LcmBase):
         db_k8srepo = None
         db_k8srepo_update = {}
 
+        exc = None
         operationState_HA = ''
         detailed_status_HA = ''
         try:
@@ -1238,6 +1243,7 @@ class K8sRepoLcm(LcmBase):
                 self.lcm_tasks.register_HA('k8srepo', 'delete', op_id,
                                            operationState=operationState_HA,
                                            detailed_status=detailed_status_HA)
+                self.db.del_one("k8srepos", {"_id": k8srepo_id})
             except DbException as e:
                 self.logger.error(logging_text + "Cannot update database: {}".format(e))
             self.lcm_tasks.remove("k8srepo", k8srepo_id, order_id)