20
20
NAMESPACES_CHART_LOCATION ,
21
21
NAMESPACES_FILE ,
22
22
NETWORK_FILE ,
23
+ SCENARIOS_DIR ,
23
24
WARGAMES_NAMESPACE_PREFIX ,
24
25
)
26
+ from .control import _run
25
27
from .k8s import (
26
28
get_default_namespace ,
27
29
get_default_namespace_or ,
@@ -238,13 +240,22 @@ def deploy_network(directory: Path, debug: bool = False, namespace: Optional[str
238
240
with network_file_path .open () as f :
239
241
network_file = yaml .safe_load (f )
240
242
243
+ needs_ln_init = False
244
+
241
245
for node in network_file ["nodes" ]:
242
246
click .echo (f"Deploying node: { node .get ('name' )} " )
243
247
try :
244
248
temp_override_file_path = ""
245
249
node_name = node .get ("name" )
246
250
node_config_override = {k : v for k , v in node .items () if k != "name" }
247
251
252
+ if (
253
+ "lnd" in node_config_override
254
+ and "channels" in node_config_override ["lnd" ]
255
+ and len (node_config_override ["lnd" ]["channels" ]) > 0
256
+ ):
257
+ needs_ln_init = True
258
+
248
259
cmd = f"{ HELM_COMMAND } { node_name } { BITCOIN_CHART_LOCATION } --namespace { namespace } -f { defaults_file_path } "
249
260
if debug :
250
261
cmd += " --debug"
@@ -268,6 +279,15 @@ def deploy_network(directory: Path, debug: bool = False, namespace: Optional[str
268
279
if temp_override_file_path :
269
280
Path (temp_override_file_path ).unlink ()
270
281
282
+ if needs_ln_init :
283
+ _run (
284
+ scenario_file = SCENARIOS_DIR / "ln_init.py" ,
285
+ debug = True ,
286
+ source_dir = SCENARIOS_DIR ,
287
+ additional_args = None ,
288
+ namespace = namespace ,
289
+ )
290
+
271
291
272
292
def deploy_namespaces (directory : Path ):
273
293
namespaces_file_path = directory / NAMESPACES_FILE
0 commit comments