Fix for test_remove_vnf failing in Heal VDU
[osm/LCM.git] / osm_lcm / lcm.py
index 851ba09..9eb37fa 100644 (file)
@@ -29,7 +29,7 @@ import logging.handlers
 import getopt
 import sys
 
-from osm_lcm import ns, prometheus, vim_sdn, netslice
+from osm_lcm import ns, vim_sdn, netslice
 from osm_lcm.ng_ro import NgRoException, NgRoClient
 from osm_lcm.ROclient import ROClient, ROClientException
 
@@ -185,6 +185,7 @@ class Lcm:
             self.db = Database(config).instance.db
 
             self.fs = Filesystem(config).instance.fs
+            self.fs.sync()
 
             # copy message configuration in order to remove 'group_id' for msg_admin
             config_message = config["message"].copy()
@@ -214,20 +215,6 @@ class Lcm:
         # contains created tasks/futures to be able to cancel
         self.lcm_tasks = TaskRegistry(self.worker_id, self.logger)
 
-        if self.config.get("tsdb") and self.config["tsdb"].get("driver"):
-            if self.config["tsdb"]["driver"] == "prometheus":
-                self.prometheus = prometheus.Prometheus(
-                    self.config["tsdb"], self.worker_id, self.loop
-                )
-            else:
-                raise LcmException(
-                    "Invalid configuration param '{}' at '[tsdb]':'driver'".format(
-                        config["tsdb"]["driver"]
-                    )
-                )
-        else:
-            self.prometheus = None
-
     async def check_RO_version(self):
         tries = 14
         last_error = None
@@ -452,6 +439,14 @@ class Lcm:
                 task = asyncio.ensure_future(self.ns.action(nsr_id, nslcmop_id))
                 self.lcm_tasks.register("ns", nsr_id, nslcmop_id, "ns_action", task)
                 return
+            elif command == "update":
+                # self.logger.debug("Update NS {}".format(nsr_id))
+                nslcmop = params
+                nslcmop_id = nslcmop["_id"]
+                nsr_id = nslcmop["nsInstanceId"]
+                task = asyncio.ensure_future(self.ns.update(nsr_id, nslcmop_id))
+                self.lcm_tasks.register("ns", nsr_id, nslcmop_id, "ns_update", task)
+                return
             elif command == "scale":
                 # self.logger.debug("Update NS {}".format(nsr_id))
                 nslcmop = params
@@ -460,6 +455,13 @@ class Lcm:
                 task = asyncio.ensure_future(self.ns.scale(nsr_id, nslcmop_id))
                 self.lcm_tasks.register("ns", nsr_id, nslcmop_id, "ns_scale", task)
                 return
+            elif command == "migrate":
+                nslcmop = params
+                nslcmop_id = nslcmop["_id"]
+                nsr_id = nslcmop["nsInstanceId"]
+                task = asyncio.ensure_future(self.ns.migrate(nsr_id, nslcmop_id))
+                self.lcm_tasks.register("ns", nsr_id, nslcmop_id, "ns_migrate", task)
+                return
             elif command == "show":
                 nsr_id = params
                 try:
@@ -483,12 +485,17 @@ class Lcm:
             elif command == "deleted":
                 return  # TODO cleaning of task just in case should be done
             elif command in (
+                "vnf_terminated",
+                "policy_updated",
                 "terminated",
                 "instantiated",
                 "scaled",
                 "actioned",
+                "updated",
+                "migrated",
             ):  # "scaled-cooldown-time"
                 return
+
         elif topic == "nsi":  # netslice LCM processes (instantiate, terminate, etc)
             if command == "instantiate":
                 # self.logger.debug("Instantiating Network Slice {}".format(nsilcmop["netsliceInstanceId"]))
@@ -684,9 +691,7 @@ class Lcm:
         # check RO version
         self.loop.run_until_complete(self.check_RO_version())
 
-        self.ns = ns.NsLcm(
-            self.msg, self.lcm_tasks, self.config, self.loop, self.prometheus
-        )
+        self.ns = ns.NsLcm(self.msg, self.lcm_tasks, self.config, self.loop)
         self.netslice = netslice.NetsliceLcm(
             self.msg, self.lcm_tasks, self.config, self.loop, self.ns
         )
@@ -701,13 +706,10 @@ class Lcm:
             self.msg, self.lcm_tasks, self.config, self.loop
         )
 
-        # configure tsdb prometheus
-        if self.prometheus:
-            self.loop.run_until_complete(self.prometheus.start())
-
         self.loop.run_until_complete(
             asyncio.gather(self.kafka_read(), self.kafka_ping())
         )
+
         # TODO
         # self.logger.debug("Terminating cancelling creation tasks")
         # self.lcm_tasks.cancel("ALL", "create")