|
5 | 5 | from time import sleep |
6 | 6 |
|
7 | 7 | import pexpect |
8 | | -from kubernetes.stream import stream |
9 | 8 | from test_base import TestBase |
10 | 9 |
|
11 | | -from warnet.k8s import get_pods_with_label, get_static_client |
| 10 | +from warnet.k8s import get_pods_with_label |
12 | 11 | from warnet.process import run_command |
13 | 12 |
|
14 | 13 |
|
@@ -47,45 +46,9 @@ def check_simln_logs(self): |
47 | 46 | def copy_results(self) -> bool: |
48 | 47 | self.log.info("Copying results") |
49 | 48 | sleep(20) |
50 | | - pod = get_pods_with_label("mission=plugin")[0] |
51 | | - v1 = get_static_client() |
| 49 | + get_pods_with_label("mission=plugin")[0] |
52 | 50 |
|
53 | | - source_path = "/config/results" |
54 | 51 | destination_path = "results" |
55 | | - os.makedirs(destination_path, exist_ok=True) |
56 | | - command = ["tar", "cf", "-", source_path] |
57 | | - |
58 | | - # Create the stream |
59 | | - resp = stream( |
60 | | - v1.connect_get_namespaced_pod_exec, |
61 | | - name=pod.metadata.name, |
62 | | - namespace=pod.metadata.namespace, |
63 | | - command=command, |
64 | | - stderr=True, |
65 | | - stdin=False, |
66 | | - stdout=True, |
67 | | - tty=False, |
68 | | - _preload_content=False, |
69 | | - ) |
70 | | - |
71 | | - # Write the tar output to a file |
72 | | - tar_file = os.path.join(destination_path, "results.tar") |
73 | | - with open(tar_file, "wb") as f: |
74 | | - while resp.is_open(): |
75 | | - resp.update(timeout=1) |
76 | | - if resp.peek_stdout(): |
77 | | - f.write(resp.read_stdout().encode("utf-8")) |
78 | | - if resp.peek_stderr(): |
79 | | - print(resp.read_stderr()) |
80 | | - |
81 | | - resp.close() |
82 | | - |
83 | | - import tarfile |
84 | | - |
85 | | - with tarfile.open(tar_file, "r") as tar: |
86 | | - tar.extractall(path=destination_path) |
87 | | - |
88 | | - os.remove(tar_file) |
89 | 52 |
|
90 | 53 | for root, _dirs, files in os.walk(destination_path): |
91 | 54 | for file_name in files: |
|
0 commit comments