summaryrefslogtreecommitdiff
path: root/clusterman/utils.py
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2023-10-29 09:37:06 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2023-10-29 09:37:06 +0100
commite34fc73d5518bcd8acb7b86a16c0cd9e253393b7 (patch)
tree0827f5985416df87e21b179853fd0d14fa7ba8d9 /clusterman/utils.py
parent38019cabe817fe0d771391d68b76dcf565c0faaf (diff)
Minor changes
Diffstat (limited to 'clusterman/utils.py')
-rw-r--r--clusterman/utils.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/clusterman/utils.py b/clusterman/utils.py
new file mode 100644
index 0000000..ad79bd2
--- /dev/null
+++ b/clusterman/utils.py
@@ -0,0 +1,13 @@
+import subprocess
+from clusterman.config import CONF
+
+def ssh_exec(host,command,use_key=True):
+ user="root" if len(CONF["ssh"]["user"]) <= 0 else CONF["ssh"]["user"]
+ key_path=CONF["ssh"]["key_path"]
+ if use_key:
+ output=subprocess.check_output(["ssh","-o", "StrictHostKeyChecking=no", "-o", "PasswordAuthentication=no", "-i", CONF["ssh"]["key_path"],"{}@{}".format(user,ip), command])
+ return output.decode("utf-8")
+ else:
+ output=subprocess.check_output(["ssh","-o", "StrictHostKeyChecking=no", "{}@{}".format(user,ip), command])
+ return output.decode("utf-8")
+