2020 NAMESPACES_CHART_LOCATION ,
2121 NAMESPACES_FILE ,
2222 NETWORK_FILE ,
23+ SCENARIOS_DIR ,
2324 WARGAMES_NAMESPACE_PREFIX ,
2425)
26+ from .control import _run
2527from .k8s import (
2628 get_default_namespace ,
2729 get_default_namespace_or ,
@@ -238,13 +240,22 @@ def deploy_network(directory: Path, debug: bool = False, namespace: Optional[str
238240 with network_file_path .open () as f :
239241 network_file = yaml .safe_load (f )
240242
243+ needs_ln_init = False
244+
241245 for node in network_file ["nodes" ]:
242246 click .echo (f"Deploying node: { node .get ('name' )} " )
243247 try :
244248 temp_override_file_path = ""
245249 node_name = node .get ("name" )
246250 node_config_override = {k : v for k , v in node .items () if k != "name" }
247251
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+
248259 cmd = f"{ HELM_COMMAND } { node_name } { BITCOIN_CHART_LOCATION } --namespace { namespace } -f { defaults_file_path } "
249260 if debug :
250261 cmd += " --debug"
@@ -268,6 +279,15 @@ def deploy_network(directory: Path, debug: bool = False, namespace: Optional[str
268279 if temp_override_file_path :
269280 Path (temp_override_file_path ).unlink ()
270281
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+
271291
272292def deploy_namespaces (directory : Path ):
273293 namespaces_file_path = directory / NAMESPACES_FILE
0 commit comments