3939config .load_incluster_config ()
4040sclient = client .CoreV1Api ()
4141pods = sclient .list_namespaced_pod (namespace = NAMESPACE )
42+ cmaps = sclient .list_namespaced_config_map (namespace = NAMESPACE )
4243
43- WARNET = []
44+ WARNET = { "tanks" : [], "lightning" : [], "channels" : []}
4445for pod in pods .items :
45- if "mission" not in pod .metadata .labels or pod . metadata . labels [ "mission" ] != "tank" :
46+ if "mission" not in pod .metadata .labels :
4647 continue
4748
48- WARNET .append (
49- {
50- "tank" : pod .metadata .name ,
51- "chain" : pod .metadata .labels ["chain" ],
52- "rpc_host" : pod .status .pod_ip ,
53- "rpc_port" : int (pod .metadata .labels ["RPCPort" ]),
54- "rpc_user" : "user" ,
55- "rpc_password" : pod .metadata .labels ["rpcpassword" ],
56- }
57- )
49+ if pod .metadata .labels ["mission" ] == "tank" :
50+ WARNET ["tanks" ].append (
51+ {
52+ "tank" : pod .metadata .name ,
53+ "chain" : pod .metadata .labels ["chain" ],
54+ "rpc_host" : pod .status .pod_ip ,
55+ "rpc_port" : int (pod .metadata .labels ["RPCPort" ]),
56+ "rpc_user" : "user" ,
57+ "rpc_password" : pod .metadata .labels ["rpcpassword" ],
58+ }
59+ )
60+
61+ if pod .metadata .labels ["mission" ] == "lightning" :
62+ WARNET ["lightning" ].append (pod .metadata .name )
63+
64+ for cm in cmaps .items :
65+ if not cm .metadata .labels or "channels" not in cm .metadata .labels :
66+ continue
67+ channel_jsons = json .loads (cm .data ["channels" ])
68+ for channel_json in channel_jsons :
69+ channel_json ["source" ] = cm .data ["source" ]
70+ WARNET ["channels" ].append (channel_json )
5871
5972
6073# Ensure that all RPC calls are made with brand new http connections
@@ -68,9 +81,9 @@ def auth_proxy_request(self, method, path, postdata):
6881
6982
7083class LND :
71- def __init__ (self , tank_name ):
84+ def __init__ (self , pod_name ):
7285 self .conn = http .client .HTTPSConnection (
73- host = f" { tank_name } -ln" , port = 8080 , timeout = 5 , context = INSECURE_CONTEXT
86+ host = pod_name , port = 8080 , timeout = 5 , context = INSECURE_CONTEXT
7487 )
7588
7689 def get (self , uri ):
@@ -153,8 +166,10 @@ def setup(self):
153166
154167 # Keep a separate index of tanks by pod name
155168 self .tanks : Dict [str , TestNode ] = {}
169+ self .lns : Dict [str , LND ] = {}
170+ self .channels = WARNET ["channels" ]
156171
157- for i , tank in enumerate (WARNET ):
172+ for i , tank in enumerate (WARNET [ "tanks" ] ):
158173 self .log .info (
159174 f"Adding TestNode #{ i } from pod { tank ['tank' ]} with IP { tank ['rpc_host' ]} "
160175 )
@@ -179,14 +194,12 @@ def setup(self):
179194 )
180195 node .rpc_connected = True
181196
182- # Tank might not even have an ln node, that's
183- # not our problem, it'll just 404 if scenario tries
184- # to connect to it
185- node .lnd = LND (tank ["tank" ])
186-
187197 self .nodes .append (node )
188198 self .tanks [tank ["tank" ]] = node
189199
200+ for ln in WARNET ["lightning" ]:
201+ self .lns [ln ] = LND (ln )
202+
190203 self .num_nodes = len (self .nodes )
191204
192205 # Set up temp directory and start logging
0 commit comments