From b4c1879bf9772a71d5b922b7c33ff406a0029e17 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Wed, 21 Sep 2022 16:20:05 +0530 Subject: [PATCH] Island: Add set_simulation_mode Island event handler --- .../cc/island_event_handlers/__init__.py | 1 + .../set_simulation_mode.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 monkey/monkey_island/cc/island_event_handlers/set_simulation_mode.py diff --git a/monkey/monkey_island/cc/island_event_handlers/__init__.py b/monkey/monkey_island/cc/island_event_handlers/__init__.py index 11343c2fa..0f111a31e 100644 --- a/monkey/monkey_island/cc/island_event_handlers/__init__.py +++ b/monkey/monkey_island/cc/island_event_handlers/__init__.py @@ -1,3 +1,4 @@ from .reset_agent_configuration import reset_agent_configuration from .reset_machine_repository import reset_machine_repository from .set_agent_configuration_per_island_mode import set_agent_configuration_per_island_mode +from .set_simulation_mode import set_simulation_mode diff --git a/monkey/monkey_island/cc/island_event_handlers/set_simulation_mode.py b/monkey/monkey_island/cc/island_event_handlers/set_simulation_mode.py new file mode 100644 index 000000000..3aff9d56d --- /dev/null +++ b/monkey/monkey_island/cc/island_event_handlers/set_simulation_mode.py @@ -0,0 +1,19 @@ +from typing import Any + +from monkey_island.cc.repository import ISimulationRepository + + +class set_simulation_mode: + """ + Callable class that sets the Island's mode + """ + + def __init__( + self, + simulation_repository: ISimulationRepository, + ): + self._simulation_repository = simulation_repository + + def __call__(self, event: Any = None): + mode = event + self._simulation_repository.set_mode(mode)