From f8a8afb0d14f5a23e6a4c5bd87d61fba5adc63d2 Mon Sep 17 00:00:00 2001 From: Benjamin Diaz Date: Tue, 20 Nov 2018 11:18:43 -0300 Subject: [PATCH] Adds use of uri in connection to MongoDB instead of host and port MON now uses a mongodb uri to connect to the database. This allows to use uris that define either a single node db or a replica set, allowing for HA scenarios. Signed-off-by: Benjamin Diaz --- docker/Dockerfile | 2 +- osm_mon/core/common_db.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index ec70d87..f843908 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -37,7 +37,7 @@ COPY . /mon RUN pip3 install /mon ENV BROKER_URI kafka:9092 -ENV MONGO_URI mongo:27017 +ENV MONGO_URI mongodb://mongo:27017 ENV DATABASE sqlite:///mon_sqlite.db ENV OS_NOTIFIER_URI localhost:8662 ENV OS_DEFAULT_GRANULARITY 300 diff --git a/osm_mon/core/common_db.py b/osm_mon/core/common_db.py index 5a76536..9549fe4 100644 --- a/osm_mon/core/common_db.py +++ b/osm_mon/core/common_db.py @@ -30,8 +30,7 @@ class CommonDbClient: def __init__(self): cfg = Config.instance() self.common_db = dbmongo.DbMongo() - self.common_db.db_connect({'host': cfg.MONGO_URI.split(':')[0], - 'port': int(cfg.MONGO_URI.split(':')[1]), + self.common_db.db_connect({'uri': cfg.MONGO_URI, 'name': 'osm', 'commonkey': cfg.OSMMON_DATABASE_COMMONKEY}) -- 2.25.1