X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fcore%2Fcommon_db.py;h=59222903a09b24ed2fade2069ac3801ca4d8035f;hb=5ac7c081ca13495185ecf6bdf302c16c25a4b759;hp=9cc9c06b85759c7f3b8e8acf712b23c65db9c653;hpb=b525e6c8619d494d4e254def394cf5b62de4df4a;p=osm%2FMON.git diff --git a/osm_mon/core/common_db.py b/osm_mon/core/common_db.py index 9cc9c06..5922290 100644 --- a/osm_mon/core/common_db.py +++ b/osm_mon/core/common_db.py @@ -21,18 +21,20 @@ # For those usages not covered by the Apache License, Version 2.0 please # contact: bdiaz@whitestack.com or glavado@whitestack.com ## -from osm_common import dbmongo +from osm_common import dbmongo, dbmemory -from osm_mon.core.settings import Config +from osm_mon.core.config import Config class CommonDbClient: - def __init__(self): - cfg = Config.instance() - self.common_db = dbmongo.DbMongo() - self.common_db.db_connect({'uri': cfg.MONGO_URI, - 'name': 'osm', - 'commonkey': cfg.OSMMON_DATABASE_COMMONKEY}) + def __init__(self, config: Config): + if config.get('database', 'driver') == "mongo": + self.common_db = dbmongo.DbMongo() + elif config.get('database', 'driver') == "memory": + self.common_db = dbmemory.DbMemory() + else: + raise Exception("Unknown database driver {}".format(config.get('section', 'driver'))) + self.common_db.db_connect(config.get("database")) def get_vnfr(self, nsr_id: str, member_index: int): vnfr = self.common_db.get_one("vnfrs",