blob: f711ec3fe6ca357fb03af4a3acd4f455a434995b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
import subprocess
from difflib import unified_diff
ROOK_CEPH_COMMAND = "minikube kubectl -- -n rook-ceph exec -it deploy/rook-ceph-tools -- "
CLUSTER_COMMAND = "minikube kubectl -- "
def execute_command(command: str) -> str:
output = ""
try:
proc = subprocess.run(command, shell=True, capture_output=True, text=True)
output = proc.stdout
except Exception as ex:
output = f"Error executing command: {ex}"
return output
def run_commands(commands: str) -> str:
commands_list = commands.split("\n")
output = ""
for cmd in commands_list:
if cmd.startswith("ceph"):
prefix = ROOK_CEPH_COMMAND
else:
prefix = CLUSTER_COMMAND
command = prefix + cmd
output = execute_command(command)
return output.strip("\n")
def run_k8s_commands(commands: str) -> str:
commands_list = commands.split("\n")
output = ""
for cmd in commands_list:
command = CLUSTER_COMMAND + cmd
output = execute_command(command)
return output.strip("\n")
def run_ceph_commands(commands: str) -> str:
commands_list = commands.split("\n")
output = ""
for cmd in commands_list:
command = ROOK_CEPH_COMMAND + cmd
output = execute_command(command)
return output.strip("\n")
def display_side_by_side(expected, got):
diff = unified_diff(expected.splitlines(), got.splitlines(), lineterm='')
print('\n'.join(diff))
|