From 638e4cd7ed955c2717f286d7c679e70efceda73e Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 20 Sep 2022 17:05:53 +0530 Subject: [PATCH] Island: Simplify logic in island_event_handlers._subscribe_clear_simulation_data_events --- .../cc/setup/island_event_handlers.py | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/monkey/monkey_island/cc/setup/island_event_handlers.py b/monkey/monkey_island/cc/setup/island_event_handlers.py index ea32e8e65..859483ee9 100644 --- a/monkey/monkey_island/cc/setup/island_event_handlers.py +++ b/monkey/monkey_island/cc/setup/island_event_handlers.py @@ -39,16 +39,11 @@ def _subscribe_clear_simulation_data_events( IslandEventTopic.CLEAR_SIMULATION_DATA, credentials_repository.remove_stolen_credentials ) - node_repository = container.resolve(INodeRepository) - island_event_queue.subscribe(IslandEventTopic.CLEAR_SIMULATION_DATA, node_repository.reset) - - agent_event_repository = container.resolve(IAgentEventRepository) - island_event_queue.subscribe( - IslandEventTopic.CLEAR_SIMULATION_DATA, agent_event_repository.reset - ) - - agent_repository = container.resolve(IAgentRepository) - island_event_queue.subscribe(IslandEventTopic.CLEAR_SIMULATION_DATA, agent_repository.reset) - - machine_repository = container.resolve(IMachineRepository) - island_event_queue.subscribe(IslandEventTopic.CLEAR_SIMULATION_DATA, machine_repository.reset) + for i_repository in [ + INodeRepository, + IAgentEventRepository, + IAgentRepository, + IMachineRepository, + ]: + repository = container.resolve(i_repository) + island_event_queue.subscribe(IslandEventTopic.CLEAR_SIMULATION_DATA, repository.reset)