Needed for feature 10938: extract_prometheus_scrape_jobs populating prom template...
[osm/LCM.git] / osm_lcm / vim_sdn.py
index f0b8f9c..d95df94 100644 (file)
@@ -56,7 +56,7 @@ class VimLcm(LcmBase):
         self.logger = logging.getLogger("lcm.vim")
         self.loop = loop
         self.lcm_tasks = lcm_tasks
-        self.ro_config = config["ro_config"]
+        self.ro_config = config["RO"]
 
         super().__init__(msg, self.logger)
 
@@ -478,7 +478,7 @@ class WimLcm(LcmBase):
         self.logger = logging.getLogger("lcm.vim")
         self.loop = loop
         self.lcm_tasks = lcm_tasks
-        self.ro_config = config["ro_config"]
+        self.ro_config = config["RO"]
 
         super().__init__(msg, self.logger)
 
@@ -826,7 +826,7 @@ class SdnLcm(LcmBase):
         self.logger = logging.getLogger("lcm.sdn")
         self.loop = loop
         self.lcm_tasks = lcm_tasks
-        self.ro_config = config["ro_config"]
+        self.ro_config = config["RO"]
 
         super().__init__(msg, self.logger)
 
@@ -1006,7 +1006,7 @@ class SdnLcm(LcmBase):
         logging_text = "Task sdn_delete={} ".format(sdn_id)
         self.logger.debug(logging_text + "Enter")
 
-        db_sdn = None
+        db_sdn = {}
         db_sdn_update = {}
         exc = None
         step = "Getting sdn from db"
@@ -1039,7 +1039,7 @@ class SdnLcm(LcmBase):
                     logging_text + "Skipping. There is not RO information at database"
                 )
             self.db.del_one("sdns", {"_id": sdn_id})
-            db_sdn = None
+            db_sdn = {}
             self.logger.debug("sdn_delete task sdn_id={} Exit Ok".format(sdn_id))
             return
 
@@ -1155,7 +1155,18 @@ 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(
@@ -1463,9 +1474,10 @@ class VcaLcm(LcmBase):
         vca_id = vca_content["_id"]
         self.logger.debug("Task vca_create={} {}".format(vca_id, "Enter"))
 
-        db_vca = None
         db_vca_update = {}
 
+        operation_state = "FAILED"
+        operation_details = ""
         try:
             self.logger.debug(
                 "Task vca_create={} {}".format(vca_id, "Getting vca from db")
@@ -1503,7 +1515,6 @@ class VcaLcm(LcmBase):
             self.logger.error("Task vca_create={} {}".format(vca_id, error_msg))
             db_vca_update["_admin.operationalState"] = "ERROR"
             db_vca_update["_admin.detailed-status"] = error_msg
-            operation_state = "FAILED"
             operation_details = error_msg
         finally:
             try:
@@ -1538,6 +1549,9 @@ class VcaLcm(LcmBase):
         db_vca_update = {}
         vca_id = vca_content["_id"]
 
+        operation_state = "FAILED"
+        operation_details = ""
+
         try:
             self.logger.debug(
                 "Task vca_delete={} {}".format(vca_id, "Deleting vca from db")
@@ -1557,7 +1571,6 @@ class VcaLcm(LcmBase):
             self.logger.error("Task vca_delete={} {}".format(vca_id, error_msg))
             db_vca_update["_admin.operationalState"] = "ERROR"
             db_vca_update["_admin.detailed-status"] = error_msg
-            operation_state = "FAILED"
             operation_details = error_msg
         finally:
             try: