summaryrefslogtreecommitdiff
path: root/clusterman/commands/node.py
diff options
context:
space:
mode:
Diffstat (limited to 'clusterman/commands/node.py')
-rw-r--r--clusterman/commands/node.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/clusterman/commands/node.py b/clusterman/commands/node.py
index 9c7be5f..24e37ba 100644
--- a/clusterman/commands/node.py
+++ b/clusterman/commands/node.py
@@ -1,5 +1,6 @@
import os, json, time, re, sys, subprocess
from clusterman.config import CONF
+from clusterman.utils import ssh_exec
def get_node_list():
nodes_path=CONF.NODE_FILE
@@ -84,15 +85,8 @@ def check(timeout):
print("Error: Some of your nodes are not reachable")
def exec(command, group=None):
- user="root" if len(CONF["ssh"]["user"]) <= 0 else CONF["ssh"]["user"]
- key_path=CONF["ssh"]["key_path"]
nodes=get_node_list() if group is None else get_node_in_group(group)
for ip in nodes:
print("----- Node {} -----".format(ip))
- if len(key_path)>0:
- output=subprocess.check_output(["ssh","-o", "StrictHostKeyChecking=no", "-o", "PasswordAuthentication=no", "-i", CONF["ssh"]["key_path"],"{}@{}".format(user,ip), " ".join(command)])
- print(output.decode("utf-8"),end="")
- else:
- output=subprocess.check_output(["ssh","-o", "StrictHostKeyChecking=no", "-o", "PasswordAuthentication=no", "{}@{}".format(user,ip), " ".join(command)])
- print(output.decode("utf-8"),end="")
+ print(ssh_exec(ip," ".join(command)))