summaryrefslogtreecommitdiff
path: root/clusterman
diff options
context:
space:
mode:
authorLoic Guegan <loic.guegan@mailbox.org>2023-10-27 13:23:06 +0200
committerLoic Guegan <loic.guegan@mailbox.org>2023-10-27 13:23:06 +0200
commita65e22fc31d123f3fc195139bfc79d4edd488400 (patch)
tree2979d4686faed71b67b6a29511465edc26284643 /clusterman
parent719cc32a70cc1ab6cd5cfdab48b0279053d757d7 (diff)
Minor changes
Diffstat (limited to 'clusterman')
-rw-r--r--clusterman/commands/node.py10
-rw-r--r--clusterman/config.py14
2 files changed, 18 insertions, 6 deletions
diff --git a/clusterman/commands/node.py b/clusterman/commands/node.py
index 087f0df..1b800d2 100644
--- a/clusterman/commands/node.py
+++ b/clusterman/commands/node.py
@@ -89,7 +89,13 @@ def check(timeout):
print("Error: Some of your nodes are not reachable")
def exec(command):
- print(["ssh", "-i", CONF["ssh_key_path"], command])
+ user="root" if len(CONF["ssh"]["user"]) <= 0 else CONF["ssh"]["user"]
+ key_path=CONF["ssh"]["key_path"]
for ip in get_node_list():
print("----- Node {} -----".format(ip))
- subprocess.run(["ssh","-o", "StrictHostKeyChecking=no", "-i", CONF["ssh_key_path"],"root@"+ip, " ".join(command)])
+ if len(key_path)>0:
+ # subprocess.run(["ssh","-o", "StrictHostKeyChecking=no", "-i", CONF["ssh_key_path"],"{}@{}".format(user,ip), " ".join(command)])
+ print(["ssh","-o", "StrictHostKeyChecking=no", "-i", CONF["ssh_key_path"],"{}@{}".format(user,ip), " ".join(command)])
+ else:
+# subprocess.run(["ssh","-o", "StrictHostKeyChecking=no", "{}@{}".format(user,ip), " ".join(command)])
+ print(["ssh","-o", "StrictHostKeyChecking=no", "{}@{}".format(user,ip), " ".join(command)])
diff --git a/clusterman/config.py b/clusterman/config.py
index b70dc16..9a5c52d 100644
--- a/clusterman/config.py
+++ b/clusterman/config.py
@@ -19,14 +19,20 @@ class Config:
},
"plugins": { "ls": "ls -al" },
"timeout": 0.5,
- "ssh_key_path": ""
+ "ssh": {
+ "key_path": "",
+ "user": "root"
+ }
}
SCHEMA_CONFIG = {
"type": "object",
"properties": {
"timeout": {"type": "number"},
"plugins": {"type": "object"},
- "ssh_key_path": {"type": "string"},
+ "ssh": {"type": "object", "properties":{
+ "key_path": {"type": "string"},
+ "user": {"type": "string"}
+ }},
"cluster": {"type": "object", "properties":{
"ip4_from": {"type": "string"},
"ip4_to": {"type": "string"},
@@ -37,8 +43,8 @@ class Config:
"required":[
"timeout",
"plugins",
- "ssh_key_path",
- "cluster"
+ "cluster",
+ "ssh"
]
}