22
22
NETWORK_FILE ,
23
23
WARGAMES_NAMESPACE_PREFIX ,
24
24
)
25
- from .k8s import get_default_namespace , wait_for_ingress_controller , wait_for_pod_ready
25
+ from .k8s import (
26
+ get_default_namespace ,
27
+ get_namespaces_by_prefix ,
28
+ wait_for_ingress_controller ,
29
+ wait_for_pod_ready ,
30
+ )
26
31
from .process import stream_command
27
32
28
33
@@ -44,11 +49,28 @@ def validate_directory(ctx, param, value):
44
49
callback = validate_directory ,
45
50
)
46
51
@click .option ("--debug" , is_flag = True )
47
- @click .option ("--namespace" , type = str )
48
- def deploy (directory , debug , namespace ):
52
+ @click .option ("--namespace" , type = str , help = "Specify a namespace in which to deploy the network" )
53
+ @click .option ("--to-all-users" , is_flag = True , help = "Deploy network to all user namespaces" )
54
+ def deploy (directory , debug , namespace , to_all_users ):
55
+ """Deploy a warnet with topology loaded from <directory>"""
56
+ if to_all_users :
57
+ namespaces = get_namespaces_by_prefix (WARGAMES_NAMESPACE_PREFIX )
58
+ for namespace in namespaces :
59
+ _deploy (directory , debug , namespace .metadata .name , False )
60
+ else :
61
+ _deploy (directory , debug , namespace , to_all_users )
62
+
63
+
64
+ def _deploy (directory , debug , namespace , to_all_users ):
49
65
"""Deploy a warnet with topology loaded from <directory>"""
50
66
directory = Path (directory )
51
67
68
+ if to_all_users :
69
+ namespaces = get_namespaces_by_prefix (WARGAMES_NAMESPACE_PREFIX )
70
+ for namespace in namespaces :
71
+ deploy (directory , debug , namespace .metadata .name , False )
72
+ return
73
+
52
74
if (directory / NETWORK_FILE ).exists ():
53
75
dl = deploy_logging_stack (directory , debug )
54
76
deploy_network (directory , debug , namespace = namespace )
0 commit comments