Bug 2175: K8s-Cluster Update is not implemented
[osm/LCM.git] / osm_lcm / vim_sdn.py
index 1641e96..3f323d6 100644 (file)
@@ -774,7 +774,7 @@ class WimLcm(LcmBase):
                         raise
             else:
                 # nothing to delete
-                self.logger.error(logging_text + "Nohing to remove at RO")
+                self.logger.error(logging_text + "Nothing to remove at RO")
             self.db.del_one("wim_accounts", {"_id": wim_id})
             db_wim = None
             self.logger.debug(logging_text + "Exit Ok")
@@ -1155,7 +1155,14 @@ class K8sClusterLcm(LcmBase):
             task2name = {}
             init_target = deep_get(db_k8scluster, ("_admin", "init"))
             step = "Launching k8scluster init tasks"
-            for task_name in ("helm-chart", "juju-bundle", "helm-chart-v3"):
+
+            k8s_deploy_methods = db_k8scluster.get("deployment_methods", {})
+            # for backwards compatibility and all-false case
+            if not any(k8s_deploy_methods.values()):
+                k8s_deploy_methods = {"helm-chart": True, "juju-bundle": True, "helm-chart-v3": True}
+            deploy_methods = tuple(filter(k8s_deploy_methods.get, k8s_deploy_methods))
+
+            for task_name in deploy_methods:
                 if init_target and task_name not in init_target:
                     continue
                 task = asyncio.ensure_future(
@@ -1288,6 +1295,32 @@ class K8sClusterLcm(LcmBase):
                 self.logger.error(logging_text + "Cannot update database: {}".format(e))
             self.lcm_tasks.remove("k8scluster", k8scluster_id, order_id)
 
+    async def edit(self, k8scluster_content, order_id):
+
+        op_id = k8scluster_content.pop("op_id", None)
+        if not self.lcm_tasks.lock_HA("k8scluster", "edit", op_id):
+            return
+
+        k8scluster_id = k8scluster_content["_id"]
+        logging_text = "Task k8scluster_edit={} ".format(k8scluster_id)
+        self.logger.debug(logging_text + "Enter")
+
+        # TODO the implementation is pending and will be part of a new feature
+        # It will support rotation of certificates, update of credentials and K8S API endpoint
+        # At the moment the operation is set as completed
+
+        operation_state = "COMPLETED"
+        operation_details = "Not implemented"
+
+        self.lcm_tasks.unlock_HA(
+            "k8scluster",
+            "edit",
+            op_id,
+            operationState=operation_state,
+            detailed_status=operation_details,
+        )
+        self.lcm_tasks.remove("k8scluster", k8scluster_id, order_id)
+
     async def delete(self, k8scluster_content, order_id):
 
         # HA tasks and backward compatibility: