@@ -190,21 +190,26 @@ def get_messages(tank_a: str, tank_b: str, chain: str):
190190 """
191191 Fetch messages from the message capture files
192192 """
193+ sclient = get_static_client ()
194+
193195 subdir = "" if chain == "main" else f"{ chain } /"
194196 base_dir = f"/root/.bitcoin/{ subdir } message_capture"
195197
196198 # Get the IP of node_b
197- cmd = f"kubectl get pod { tank_b } -o jsonpath='{{.status.podIP}}'"
198- tank_b_ip = run_command ( cmd ). strip ()
199+ tank_b_pod : V1Pod = sclient . read_namespaced_pod ( name = tank_b , namespace = get_default_namespace ())
200+ tank_b_ip = tank_b_pod . status . pod_ip
199201
200202 # Get the service IP of node_b
201- cmd = f"kubectl get service { tank_b } -o jsonpath='{{.spec.clusterIP}}'"
202- tank_b_service_ip = run_command (cmd ).strip ()
203+ tank_b_service : V1Service = sclient .read_namespaced_service (
204+ name = tank_b , namespace = get_default_namespace ()
205+ )
206+ tank_b_service_ip = tank_b_service .spec .cluster_ip
203207
204208 # List directories in the message capture folder
205- cmd = f"kubectl exec { tank_a } -- ls { base_dir } "
206209
207- dirs = run_command (cmd ).splitlines ()
210+ resp = kexec (tank_a , get_default_namespace (), ["ls" , base_dir ])
211+
212+ dirs = resp .splitlines ()
208213
209214 messages = []
210215
@@ -213,18 +218,15 @@ def get_messages(tank_a: str, tank_b: str, chain: str):
213218 for file , outbound in [["msgs_recv.dat" , False ], ["msgs_sent.dat" , True ]]:
214219 file_path = f"{ base_dir } /{ dir_name } /{ file } "
215220 # Fetch the file contents from the container
216- cmd = f"kubectl exec { tank_a } -- cat { file_path } "
217- import subprocess
218-
219- blob = subprocess .run (
220- cmd , shell = True , capture_output = True , executable = "bash"
221- ).stdout
222221
222+ resp = kexec (tank_a , get_default_namespace (), ["base64" , file_path ])
223+ resp_bytes = base64 .b64decode (resp )
223224 # Parse the blob
224- json = parse_raw_messages (blob , outbound )
225+ json = parse_raw_messages (resp_bytes , outbound )
225226 messages = messages + json
226227
227228 messages .sort (key = lambda x : x ["time" ])
229+
228230 return messages
229231
230232
0 commit comments