From 5f25debfd2e03199ac667e7e90da5a02606692bc Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 2 Jun 2021 20:12:03 -0400 Subject: [PATCH] island: Decouple mongo_setup from IslandConfigOptions --- monkey/monkey_island/cc/server_setup.py | 2 +- monkey/monkey_island/cc/setup/mongo/mongo_setup.py | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/monkey/monkey_island/cc/server_setup.py b/monkey/monkey_island/cc/server_setup.py index 1b5803364..0ee516db3 100644 --- a/monkey/monkey_island/cc/server_setup.py +++ b/monkey/monkey_island/cc/server_setup.py @@ -48,7 +48,7 @@ def run_monkey_island(): _initialize_global_resources(config_options, server_config_path) if config_options.start_mongodb: - mongo_db_process = start_mongodb(config_options) + mongo_db_process = start_mongodb(config_options.data_dir) register_mongo_shutdown_callback(mongo_db_process) connect_to_mongodb() diff --git a/monkey/monkey_island/cc/setup/mongo/mongo_setup.py b/monkey/monkey_island/cc/setup/mongo/mongo_setup.py index 2920fc8bb..44252c202 100644 --- a/monkey/monkey_island/cc/setup/mongo/mongo_setup.py +++ b/monkey/monkey_island/cc/setup/mongo/mongo_setup.py @@ -9,7 +9,6 @@ from monkey_island.cc.environment.utils import create_secure_directory from monkey_island.cc.setup.mongo import mongo_connector from monkey_island.cc.setup.mongo.mongo_connector import MONGO_DB_HOST, MONGO_DB_NAME, MONGO_DB_PORT from monkey_island.cc.setup.mongo.mongo_db_process import MongoDbProcess -from monkey_island.setup.island_config_options import IslandConfigOptions DB_DIR_NAME = "db" MONGO_URL = os.environ.get( @@ -21,10 +20,10 @@ MINIMUM_MONGO_DB_VERSION_REQUIRED = "4.2.0" logger = logging.getLogger(__name__) -def start_mongodb(config_options: IslandConfigOptions) -> MongoDbProcess: - db_dir = _create_db_dir(config_options.data_dir) +def start_mongodb(data_dir: str) -> MongoDbProcess: + db_dir = _create_db_dir(data_dir) - mongo_db_process = MongoDbProcess(db_dir=db_dir, logging_dir=config_options.data_dir) + mongo_db_process = MongoDbProcess(db_dir=db_dir, logging_dir=data_dir) mongo_db_process.start() return mongo_db_process