Merge branch feature7928. It includes feature5837
[osm/LCM.git] / osm_lcm / lcm.py
index d8ac91f..3569904 100644 (file)
@@ -400,7 +400,7 @@ class Lcm:
                 return
         elif topic == "vim_account":
             vim_id = params["_id"]
-            if command == "create" or command == "created":
+            if command in ("create", "created"):
                 task = asyncio.ensure_future(self.vim.create(params, order_id))
                 self.lcm_tasks.register("vim_account", vim_id, order_id, "vim_create", task)
                 return
@@ -413,13 +413,15 @@ class Lcm:
                 print("not implemented show with vim_account")
                 sys.stdout.flush()
                 return
-            elif command == "edit" or command == "edited":
+            elif command in ("edit", "edited"):
                 task = asyncio.ensure_future(self.vim.edit(params, order_id))
                 self.lcm_tasks.register("vim_account", vim_id, order_id, "vim_edit", task)
                 return
+            elif command == "deleted":
+                return  # TODO cleaning of task just in case should be done
         elif topic == "wim_account":
             wim_id = params["_id"]
-            if command == "create" or command == "created":
+            if command in ("create", "created"):
                 task = asyncio.ensure_future(self.wim.create(params, order_id))
                 self.lcm_tasks.register("wim_account", wim_id, order_id, "wim_create", task)
                 return
@@ -432,13 +434,15 @@ class Lcm:
                 print("not implemented show with wim_account")
                 sys.stdout.flush()
                 return
-            elif command == "edit" or command == "edited":
+            elif command in ("edit", "edited"):
                 task = asyncio.ensure_future(self.wim.edit(params, order_id))
                 self.lcm_tasks.register("wim_account", wim_id, order_id, "wim_edit", task)
                 return
+            elif command == "deleted":
+                return  # TODO cleaning of task just in case should be done
         elif topic == "sdn":
             _sdn_id = params["_id"]
-            if command == "create" or command == "created":
+            if command in ("create", "created"):
                 task = asyncio.ensure_future(self.sdn.create(params, order_id))
                 self.lcm_tasks.register("sdn", _sdn_id, order_id, "sdn_create", task)
                 return
@@ -447,10 +451,12 @@ class Lcm:
                 task = asyncio.ensure_future(self.sdn.delete(params, order_id))
                 self.lcm_tasks.register("sdn", _sdn_id, order_id, "sdn_delete", task)
                 return
-            elif command == "edit" or command == "edited":
+            elif command in ("edit", "edited"):
                 task = asyncio.ensure_future(self.sdn.edit(params, order_id))
                 self.lcm_tasks.register("sdn", _sdn_id, order_id, "sdn_edit", task)
                 return
+            elif command == "deleted":
+                return  # TODO cleaning of task just in case should be done
         self.logger.critical("unknown topic {} and command '{}'".format(topic, command))
 
     async def kafka_read(self):
@@ -520,7 +526,7 @@ class Lcm:
         # and not parse integer or boolean
         try:
             with open(config_file) as f:
-                conf = yaml.load(f)
+                conf = yaml.load(f, Loader=yaml.Loader)
             for k, v in environ.items():
                 if not k.startswith("OSMLCM_"):
                     continue
@@ -597,6 +603,7 @@ def health_check():
 if __name__ == '__main__':
 
     try:
+        print("SYS.PATH='{}'".format(sys.path))
         # load parameters and configuration
         # -h
         # -c value