From: Juan Date: Mon, 12 Nov 2018 19:17:08 +0000 (-0300) Subject: Added support for mongodb High availability, changed cfg from host, port to url X-Git-Tag: v5.0.0~2 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F79%2F6879%2F3;p=osm%2Fcommon.git Added support for mongodb High availability, changed cfg from host, port to url Change-Id: I8a5d2174927120e2706eaba5bdee38f60d4a4a9d Signed-off-by: Juan --- diff --git a/osm_common/dbmongo.py b/osm_common/dbmongo.py index 0f89c96..6159e6a 100644 --- a/osm_common/dbmongo.py +++ b/osm_common/dbmongo.py @@ -80,7 +80,10 @@ class DbMongo(DbBase): master_key = config.get("commonkey") or config.get("masterpassword") if master_key: self.set_secret_key(master_key) - self.client = MongoClient(config["host"], config["port"]) + if config.get("url"): + self.client = MongoClient(config["url"]) + else: + self.client = MongoClient(config["host"], config["port"]) # TODO add as parameters also username=config.get("user"), password=config.get("password")) # when all modules are ready self.db = self.client[config["name"]]