From ec566a093b1d4023e675426ecf9ae3d4768b2436 Mon Sep 17 00:00:00 2001 From: Juan Date: Wed, 21 Nov 2018 12:21:34 -0300 Subject: [PATCH] added env vars for mongo ha Change-Id: Ied541f300e819eacbc31426089eb7ca547b59f34 Signed-off-by: Juan --- docker/Dockerfile | 3 +-- osm_policy_module/common/common_db_client.py | 3 +-- osm_policy_module/common/lcm_client.py | 3 +-- osm_policy_module/core/config.py | 3 +-- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 5953489..91bc5f6 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -41,8 +41,7 @@ ENV OSMPOL_MESSAGE_HOST kafka ENV OSMPOL_MESSAGE_PORT 9092 ENV OSMPOL_DATABASE_DRIVER mongo -ENV OSMPOL_DATABASE_HOST mongo -ENV OSMPOL_DATABASE_PORT 27017 +ENV OSMPOL_DATABASE_URI mongodb://mongo:27017 ENV OSMPOL_SQL_DATABASE_URI sqlite:///policy_module.db diff --git a/osm_policy_module/common/common_db_client.py b/osm_policy_module/common/common_db_client.py index 83bb46c..41ce975 100644 --- a/osm_policy_module/common/common_db_client.py +++ b/osm_policy_module/common/common_db_client.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.OSMPOL_DATABASE_HOST, - 'port': int(cfg.OSMPOL_DATABASE_PORT), + self.common_db.db_connect({'uri': cfg.OSMPOL_DATABASE_URI, 'name': 'osm'}) def get_vnfr(self, nsr_id: str, member_index: int): diff --git a/osm_policy_module/common/lcm_client.py b/osm_policy_module/common/lcm_client.py index 3d8012f..05378d7 100644 --- a/osm_policy_module/common/lcm_client.py +++ b/osm_policy_module/common/lcm_client.py @@ -42,8 +42,7 @@ class LcmClient: self.kafka_server = '{}:{}'.format(cfg.OSMPOL_MESSAGE_HOST, cfg.OSMPOL_MESSAGE_PORT) self.common_db = dbmongo.DbMongo() - self.common_db.db_connect({'host': cfg.OSMPOL_DATABASE_HOST, - 'port': int(cfg.OSMPOL_DATABASE_PORT), + self.common_db.db_connect({'uri': cfg.OSMPOL_DATABASE_URI, 'name': 'osm'}) if not loop: loop = asyncio.get_event_loop() diff --git a/osm_policy_module/core/config.py b/osm_policy_module/core/config.py index 94dec98..55287cc 100644 --- a/osm_policy_module/core/config.py +++ b/osm_policy_module/core/config.py @@ -63,8 +63,7 @@ class Config(object): CfgParam('OSMPOL_MESSAGE_HOST', "localhost", six.text_type), CfgParam('OSMPOL_MESSAGE_PORT', 9092, int), CfgParam('OSMPOL_DATABASE_DRIVER', "mongo", six.text_type), - CfgParam('OSMPOL_DATABASE_HOST', "mongo", six.text_type), - CfgParam('OSMPOL_DATABASE_PORT', 27017, int), + CfgParam('OSMPOL_DATABASE_URI', "mongodb://mongo:27017", six.text_type), CfgParam('OSMPOL_SQL_DATABASE_URI', "sqlite:///policy_module.db", six.text_type), CfgParam('OSMPOL_LOG_LEVEL', "INFO", six.text_type), CfgParam('OSMPOL_KAFKA_LOG_LEVEL', "WARN", six.text_type), -- 2.25.1