From ed8337414c35771fabb8334a7c95decfa6bd762c Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Sun, 29 Oct 2023 09:46:58 +0100 Subject: Minor changes --- clusterman/utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'clusterman/utils.py') 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 -- cgit v1.2.3