Added support for mongodb High availability, changed cfg from host, port to url 79/6879/3
authorJuan <jquiroga@whitestack.com>
Mon, 12 Nov 2018 19:17:08 +0000 (16:17 -0300)
committerJuan <jquiroga@whitestack.com>
Thu, 15 Nov 2018 18:41:11 +0000 (15:41 -0300)
Change-Id: I8a5d2174927120e2706eaba5bdee38f60d4a4a9d
Signed-off-by: Juan <jquiroga@whitestack.com>
osm_common/dbmongo.py

index 0f89c96..6159e6a 100644 (file)
@@ -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"]]