summaryrefslogtreecommitdiff
path: root/clusterman/utils.py
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2023-10-29 09:46:58 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2023-10-29 09:46:58 +0100
commited8337414c35771fabb8334a7c95decfa6bd762c (patch)
tree2b69e0ce803d3e9d1e970feb3addfe9c4ea675de /clusterman/utils.py
parentf4da1431425bb83e14f199ddd06896165182a0df (diff)
Minor changes
Diffstat (limited to 'clusterman/utils.py')
-rw-r--r--clusterman/utils.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/clusterman/utils.py b/clusterman/utils.py
index 36822fe..5fa66b2 100644
--- a/clusterman/utils.py
+++ b/clusterman/utils.py
@@ -11,6 +11,15 @@ def ssh_exec(host,command,use_key=True):
output=subprocess.check_output(["ssh","-o", "StrictHostKeyChecking=no", "{}@{}".format(user,ip), command])
return output.decode("utf-8")
+def ping_test(host, timeout=None):
+ t=CONF["timeout"]
+ if timeout is not None:
+ t=timeout
+ try:
+ subprocess.run(["ping", "-c", "1", "-W", str(t), host],capture_output=True,check=True)
+ return 0
+ except:
+ return 1
def get_node_list():
nodes_path=CONF.NODE_FILE