X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=osm_lcm%2Flcm.py;h=de829bd5c3d2733b227ff78f3e7d1db3bf3c8373;hb=refs%2Fchanges%2F26%2F8326%2F2;hp=d8ac91f9597a25d23ba64b0ab14f916e6cf6fc0e;hpb=9f9c6f2e8b8e978deaa4fb6e1482c0656ce4bd45;p=osm%2FLCM.git diff --git a/osm_lcm/lcm.py b/osm_lcm/lcm.py index d8ac91f..de829bd 100644 --- a/osm_lcm/lcm.py +++ b/osm_lcm/lcm.py @@ -38,7 +38,7 @@ from time import time, sleep from osm_lcm.lcm_utils import versiontuple, LcmException, TaskRegistry, LcmExceptionExit from osm_lcm import version as lcm_version, version_date as lcm_version_date -from osm_common import dbmemory, dbmongo, fslocal, msglocal, msgkafka +from osm_common import dbmemory, dbmongo, fslocal, fsmongo, msglocal, msgkafka from osm_common import version as common_version from osm_common.dbbase import DbException from osm_common.fsbase import FsException @@ -158,6 +158,9 @@ class Lcm: if config["storage"]["driver"] == "local": self.fs = fslocal.FsLocal() self.fs.fs_connect(config["storage"]) + elif config["storage"]["driver"] == "mongo": + self.fs = fsmongo.FsMongo() + self.fs.fs_connect(config["storage"]) else: raise LcmException("Invalid configuration param '{}' at '[storage]':'driver'".format( config["storage"]["driver"])) @@ -400,7 +403,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 +416,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 +437,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 +454,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 +529,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 +606,7 @@ def health_check(): if __name__ == '__main__': try: + print("SYS.PATH='{}'".format(sys.path)) # load parameters and configuration # -h # -c value