diff --git a/monkey/monkey_island/cc/resources/island_mode.py b/monkey/monkey_island/cc/resources/island_mode.py index a7d0a81de..7698fca9d 100644 --- a/monkey/monkey_island/cc/resources/island_mode.py +++ b/monkey/monkey_island/cc/resources/island_mode.py @@ -5,9 +5,8 @@ import flask_restful from flask import make_response, request from monkey_island.cc.resources.auth.auth import jwt_required -from monkey_island.cc.services.mode.get_island_mode_service import ModeNotSetError, get_mode +from monkey_island.cc.services.mode.island_mode_service import ModeNotSetError, get_mode, set_mode from monkey_island.cc.services.mode.mode_enum import IslandModeEnum -from monkey_island.cc.services.mode.set_island_mode_service import set_mode logger = logging.getLogger(__name__) diff --git a/monkey/monkey_island/cc/services/config.py b/monkey/monkey_island/cc/services/config.py index 2dfcd175b..8a107f5b5 100644 --- a/monkey/monkey_island/cc/services/config.py +++ b/monkey/monkey_island/cc/services/config.py @@ -10,7 +10,7 @@ from monkey_island.cc.database import mongo from monkey_island.cc.server_utils.encryptor import get_encryptor from monkey_island.cc.services.config_manipulator import update_config_per_mode from monkey_island.cc.services.config_schema.config_schema import SCHEMA -from monkey_island.cc.services.mode.get_island_mode_service import ModeNotSetError, get_mode +from monkey_island.cc.services.mode.island_mode_service import ModeNotSetError, get_mode from monkey_island.cc.services.post_breach_files import PostBreachFilesService from monkey_island.cc.services.utils.network_utils import local_ip_addresses diff --git a/monkey/monkey_island/cc/services/mode/get_island_mode_service.py b/monkey/monkey_island/cc/services/mode/get_island_mode_service.py deleted file mode 100644 index 1f27ad3b1..000000000 --- a/monkey/monkey_island/cc/services/mode/get_island_mode_service.py +++ /dev/null @@ -1,15 +0,0 @@ -from monkey_island.cc.models.island_mode_model import IslandMode - - -def get_mode() -> str: - if IslandMode.objects: - mode = IslandMode.objects[0].mode - return mode - else: - raise ModeNotSetError - - -class ModeNotSetError(Exception): - """ - Throw this exception when island mode is not set. - """ diff --git a/monkey/monkey_island/cc/services/mode/set_island_mode_service.py b/monkey/monkey_island/cc/services/mode/island_mode_service.py similarity index 69% rename from monkey/monkey_island/cc/services/mode/set_island_mode_service.py rename to monkey/monkey_island/cc/services/mode/island_mode_service.py index ef6f5e5b4..5109c6910 100644 --- a/monkey/monkey_island/cc/services/mode/set_island_mode_service.py +++ b/monkey/monkey_island/cc/services/mode/island_mode_service.py @@ -15,3 +15,17 @@ def set_mode(mode: IslandModeEnum): LOG.error( "Could not apply configuration changes per mode. Using default advanced configuration." ) + + +def get_mode() -> str: + if IslandMode.objects: + mode = IslandMode.objects[0].mode + return mode + else: + raise ModeNotSetError + + +class ModeNotSetError(Exception): + """ + Throw this exception when island mode is not set. + """