island: Move `get_mode()` and `set_mode()` to a single file `island_mode_service.py`
This commit is contained in:
parent
7b79c297b9
commit
af7651c53b
|
@ -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__)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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.
|
||||
"""
|
|
@ -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.
|
||||
"""
|
Loading…
Reference in New Issue