Support for mongodb replicaset connection (HA). 62/10562/1 v8.0
authorVijay Nag B S <vijaynag.bs@tataelxsi.co.in>
Tue, 29 Sep 2020 11:53:57 +0000 (17:23 +0530)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Mon, 29 Mar 2021 13:33:38 +0000 (15:33 +0200)
Change-Id: I36d582f177d36b93b9913dd781c50ac34b2bbb60
Signed-off-by: Vijay Nag B S <vijaynag.bs@tataelxsi.co.in>
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osm_common/dbmongo.py

index 3de900b..16ab881 100644 (file)
@@ -99,9 +99,9 @@ class DbMongo(DbBase):
                 self.database_key = master_key
                 self.set_secret_key(master_key)
             if config.get("uri"):
-                self.client = MongoClient(config["uri"])
+                self.client = MongoClient(config["uri"], replicaSet=config.get("replicaset", None))
             else:
-                self.client = MongoClient(config["host"], config["port"])
+                self.client = MongoClient(config["host"], config["port"], replicaSet=config.get("replicaset", None))
             # TODO add as parameters also username=config.get("user"), password=config.get("password"))
             # when all modules are ready
             self.db = self.client[config["name"]]