island: Separate `island_mode_service.py` to separate files for get and

set mode services
This commit is contained in:
Shreya Malviya 2021-07-19 15:34:48 +05:30
parent d3de80feed
commit f1a3e1fc25
3 changed files with 12 additions and 8 deletions

View File

@ -5,7 +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.island_mode_service import ModeNotSetError, get_mode, set_mode
from monkey_island.cc.services.mode.get_island_mode_service import ModeNotSetError, get_mode
from monkey_island.cc.services.mode.set_island_mode_service import set_mode
from monkey_island.cc.services.mode.mode_enum import IslandModeEnum
logger = logging.getLogger(__name__)

View File

@ -1,11 +1,4 @@
from monkey_island.cc.models.island_mode_model import IslandMode
from monkey_island.cc.services.mode.mode_enum import IslandModeEnum
def set_mode(mode: IslandModeEnum):
island_mode_model = IslandMode()
island_mode_model.mode = mode.value
island_mode_model.save()
def get_mode() -> str:

View File

@ -0,0 +1,10 @@
from monkey_island.cc.models.island_mode_model import IslandMode
from monkey_island.cc.services.mode.mode_enum import IslandModeEnum
from monkey_island.cc.services.config import ConfigService
def set_mode(mode: IslandModeEnum):
island_mode_model = IslandMode()
island_mode_model.mode = mode.value
island_mode_model.save()
ConfigService.update_config_on_mode_set(mode.value)