diff options
Diffstat (limited to '')
-rw-r--r-- | src/pybind/mgr/rook/ci/tests/features/steps/utils.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/pybind/mgr/rook/ci/tests/features/steps/utils.py b/src/pybind/mgr/rook/ci/tests/features/steps/utils.py new file mode 100644 index 000000000..41a71d0fb --- /dev/null +++ b/src/pybind/mgr/rook/ci/tests/features/steps/utils.py @@ -0,0 +1,29 @@ +import subprocess + +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") |