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