39
39
config .load_incluster_config ()
40
40
sclient = client .CoreV1Api ()
41
41
pods = sclient .list_namespaced_pod (namespace = NAMESPACE )
42
+ cmaps = sclient .list_namespaced_config_map (namespace = NAMESPACE )
42
43
43
- WARNET = []
44
+ WARNET = { "tanks" : [], "lightning" : [], "channels" : []}
44
45
for 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 :
46
47
continue
47
48
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 )
58
71
59
72
60
73
# Ensure that all RPC calls are made with brand new http connections
@@ -68,9 +81,9 @@ def auth_proxy_request(self, method, path, postdata):
68
81
69
82
70
83
class LND :
71
- def __init__ (self , tank_name ):
84
+ def __init__ (self , pod_name ):
72
85
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
74
87
)
75
88
76
89
def get (self , uri ):
@@ -153,8 +166,10 @@ def setup(self):
153
166
154
167
# Keep a separate index of tanks by pod name
155
168
self .tanks : Dict [str , TestNode ] = {}
169
+ self .lns : Dict [str , LND ] = {}
170
+ self .channels = WARNET ["channels" ]
156
171
157
- for i , tank in enumerate (WARNET ):
172
+ for i , tank in enumerate (WARNET [ "tanks" ] ):
158
173
self .log .info (
159
174
f"Adding TestNode #{ i } from pod { tank ['tank' ]} with IP { tank ['rpc_host' ]} "
160
175
)
@@ -179,14 +194,12 @@ def setup(self):
179
194
)
180
195
node .rpc_connected = True
181
196
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
-
187
197
self .nodes .append (node )
188
198
self .tanks [tank ["tank" ]] = node
189
199
200
+ for ln in WARNET ["lightning" ]:
201
+ self .lns [ln ] = LND (ln )
202
+
190
203
self .num_nodes = len (self .nodes )
191
204
192
205
# Set up temp directory and start logging
0 commit comments