@@ -125,44 +125,26 @@ async def stop_scenario(self, federation_id: str = ""):
125125 - Supports both Linux/macOS ('.sh') and Windows ('.ps1') script files.
126126 - Any errors during file removal are logged with the traceback.
127127 """
128- federation_name = await self ._remove_nebula_federation_from_pool (federation_id )
129- if not federation_name :
128+ federation = await self ._remove_nebula_federation_from_pool (federation_id )
129+ if not federation :
130130 return False
131131
132- # When stopping the nodes, we need to remove the current_scenario_commands.sh file -> it will cause the nodes to stop using PIDs
133132 try :
134- nebula_config_dir = os .environ .get ("NEBULA_CONFIG_DIR" )
135- if not nebula_config_dir :
136- current_dir = os .path .dirname (__file__ )
137- nebula_base_dir = os .path .abspath (os .path .join (current_dir , ".." , ".." ))
138- nebula_config_dir = os .path .join (nebula_base_dir , "app" , "config" )
139- self .logger .info (f"NEBULA_CONFIG_DIR not found. Using default path: { nebula_config_dir } " )
140- if federation_id :
141- if os .environ .get ("NEBULA_HOST_PLATFORM" ) == "windows" :
142- scenario_commands_file = os .path .join (
143- nebula_config_dir , federation_name , "current_scenario_commands.ps1"
144- )
145- else :
146- scenario_commands_file = os .path .join (
147- nebula_config_dir , federation_name , "current_scenario_commands.sh"
148- )
149- if os .path .exists (scenario_commands_file ):
150- os .remove (scenario_commands_file )
133+ if os .environ .get ("NEBULA_HOST_PLATFORM" ) == "windows" :
134+ scenario_commands_file = os .path .join (
135+ federation .config_dir , "current_scenario_commands.ps1"
136+ )
151137 else :
152- if os .environ .get ("NEBULA_HOST_PLATFORM" ) == "windows" :
153- files = glob .glob (
154- os .path .join (nebula_config_dir , "**/current_scenario_commands.ps1" ), recursive = True
155- )
156- else :
157- files = glob .glob (
158- os .path .join (nebula_config_dir , "**/current_scenario_commands.sh" ), recursive = True
159- )
160- for file in files :
161- os .remove (file )
162- return True
138+ scenario_commands_file = os .path .join (
139+ federation .config_dir , "current_scenario_commands.sh"
140+ )
141+ if os .path .exists (scenario_commands_file ):
142+ os .remove (scenario_commands_file )
143+ self .logger .info (f"Scenario commands file removed: { scenario_commands_file } " )
144+ else :
145+ self .logger .info (f"Scenario commands file not found: { scenario_commands_file } " )
163146 except Exception as e :
164- self .logger .exception (f"Error while removing current_scenario_commands.sh file: { e } " )
165- return False
147+ self .logger .exception (f"Error while removing current_scenario_commands file: { e } " )
166148
167149 async def update_nodes (self , federation_id : str , node_update_request : NodeUpdateRequest ):
168150 config = node_update_request .config
@@ -229,15 +211,15 @@ async def _add_nebula_federation_to_pool(self, federation_id: str, user: str):
229211 self .logger .info (f"ERROR: trying to add ({ federation_id } ) to federations pool.." )
230212 return fed
231213
232- async def _remove_nebula_federation_from_pool (self , federation_id : str ):
214+ async def _remove_nebula_federation_from_pool (self , federation_id : str ) -> NebulaFederationProcesses | None :
233215 async with self ._federations_dict_lock :
234216 if federation_id in self .nfp :
235217 federation = self .nfp .pop (federation_id )
236218 self .logger .info (f"SUCCESS: Federation ID: ({ federation_id } ) removed from pool" )
237- return federation . scenario_name
219+ return federation
238220 else :
239221 self .logger .info (f"ERROR: trying to remove ({ federation_id } ) from federations pool.." )
240- return ""
222+ return None
241223
242224 async def _send_to_hub (self , path , payload , scenario_name = "" , federation_id = "" ):
243225 try :
0 commit comments