@@ -216,11 +216,21 @@ def get_active_network(namespace):
216
216
"--source_dir" , type = click .Path (exists = True , file_okay = False , dir_okay = True ), required = False
217
217
)
218
218
@click .argument ("additional_args" , nargs = - 1 , type = click .UNPROCESSED )
219
- def run (scenario_file : str , debug : bool , source_dir , additional_args : tuple [str ]):
219
+ @click .option ("--namespace" , default = None , show_default = True )
220
+ def run (
221
+ scenario_file : str ,
222
+ debug : bool ,
223
+ source_dir ,
224
+ additional_args : tuple [str ],
225
+ namespace : Optional [str ],
226
+ ):
220
227
"""
221
228
Run a scenario from a file.
222
229
Pass `-- --help` to get individual scenario help
223
230
"""
231
+ if not namespace :
232
+ namespace = get_default_namespace ()
233
+
224
234
scenario_path = Path (scenario_file ).resolve ()
225
235
scenario_dir = scenario_path .parent if not source_dir else Path (source_dir ).resolve ()
226
236
scenario_name = scenario_path .stem
@@ -230,7 +240,6 @@ def run(scenario_file: str, debug: bool, source_dir, additional_args: tuple[str]
230
240
231
241
# Collect tank data for warnet.json
232
242
name = f"commander-{ scenario_name .replace ('_' , '' )} -{ int (time .time ())} "
233
- namespace = get_default_namespace ()
234
243
tankpods = get_mission ("tank" )
235
244
tanks = [
236
245
{
@@ -318,18 +327,20 @@ def filter(path):
318
327
print (f"Error: { e .stderr } " )
319
328
320
329
# upload scenario files and network data to the init container
321
- wait_for_init (name )
330
+ wait_for_init (name , namespace = namespace )
322
331
if write_file_to_container (
323
- name , "init" , "/shared/warnet.json" , warnet_data
324
- ) and write_file_to_container (name , "init" , "/shared/archive.pyz" , archive_data ):
332
+ name , "init" , "/shared/warnet.json" , warnet_data , namespace = namespace
333
+ ) and write_file_to_container (
334
+ name , "init" , "/shared/archive.pyz" , archive_data , namespace = namespace
335
+ ):
325
336
print (f"Successfully uploaded scenario data to commander: { scenario_name } " )
326
337
327
338
if debug :
328
339
print ("Waiting for commander pod to start..." )
329
- wait_for_pod (name )
330
- _logs (pod_name = name , follow = True )
340
+ wait_for_pod (name , namespace = namespace )
341
+ _logs (pod_name = name , follow = True , namespace = namespace )
331
342
print ("Deleting pod..." )
332
- delete_pod (name )
343
+ delete_pod (name , namespace = namespace )
333
344
334
345
335
346
@click .command ()
0 commit comments