diff --git a/monkey/monkey_island/cc/setup/island_event_handlers.py b/monkey/monkey_island/cc/setup/island_event_handlers.py index 65d9cff51..46429f292 100644 --- a/monkey/monkey_island/cc/setup/island_event_handlers.py +++ b/monkey/monkey_island/cc/setup/island_event_handlers.py @@ -28,25 +28,23 @@ def setup_island_event_handlers(container: DIContainer): def _subscribe_reset_agent_configuration_events( island_event_queue: IIslandEventQueue, container: DIContainer ): - island_event_queue.subscribe( - IslandEventTopic.RESET_AGENT_CONFIGURATION, container.resolve(reset_agent_configuration) - ) + topic = IslandEventTopic.RESET_AGENT_CONFIGURATION + + island_event_queue.subscribe(topic, container.resolve(reset_agent_configuration)) def _subscribe_clear_simulation_data_events( island_event_queue: IIslandEventQueue, container: DIContainer ): + topic = IslandEventTopic.CLEAR_SIMULATION_DATA + legacy_database_reset = partial(Database.reset_db, reset_config=False) - island_event_queue.subscribe(IslandEventTopic.CLEAR_SIMULATION_DATA, legacy_database_reset) + island_event_queue.subscribe(topic, legacy_database_reset) credentials_repository = container.resolve(ICredentialsRepository) - island_event_queue.subscribe( - IslandEventTopic.CLEAR_SIMULATION_DATA, credentials_repository.remove_stolen_credentials - ) + island_event_queue.subscribe(topic, credentials_repository.remove_stolen_credentials) - island_event_queue.subscribe( - IslandEventTopic.CLEAR_SIMULATION_DATA, container.resolve(reset_machine_repository) - ) + island_event_queue.subscribe(topic, container.resolve(reset_machine_repository)) for i_repository in [ INodeRepository, @@ -54,15 +52,14 @@ def _subscribe_clear_simulation_data_events( IAgentRepository, ]: repository = container.resolve(i_repository) - island_event_queue.subscribe(IslandEventTopic.CLEAR_SIMULATION_DATA, repository.reset) + island_event_queue.subscribe(topic, repository.reset) def _subscribe_set_island_mode_events( island_event_queue: IIslandEventQueue, container: DIContainer ): - island_event_queue.subscribe( - IslandEventTopic.SET_ISLAND_MODE, container.resolve(set_agent_configuration_per_island_mode) - ) - island_event_queue.subscribe( - IslandEventTopic.SET_ISLAND_MODE, container.resolve(set_simulation_mode) - ) + topic = IslandEventTopic.SET_ISLAND_MODE + + island_event_queue.subscribe(topic, container.resolve(set_agent_configuration_per_island_mode)) + + island_event_queue.subscribe(topic, container.resolve(set_simulation_mode))