summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <loic.guegan@mailbox.org>2023-10-27 13:54:45 +0200
committerLoic Guegan <loic.guegan@mailbox.org>2023-10-27 13:54:45 +0200
commitcd4e28906b15721370a9cf66b79b3e7cc5c4cc84 (patch)
treeda236150784d7243e9b41efcb19d046e58b048ac
parent839f4d5a30f2659550361fa473253afb5786f444 (diff)
Minor changes
-rw-r--r--clusterman/commands/node.py38
1 files changed, 17 insertions, 21 deletions
diff --git a/clusterman/commands/node.py b/clusterman/commands/node.py
index 6aec92a..4b238d6 100644
--- a/clusterman/commands/node.py
+++ b/clusterman/commands/node.py
@@ -64,29 +64,25 @@ def scan(timeout):
CONF.save()
def check(timeout):
- nodes_path=CONF.NODE_FILE
- nodes=None
- if os.path.exists(nodes_path):
- with open(nodes_path) as f:
- nodes=json.load(f)
- else:
+ nodes=get_node_list()
+ if len(nodes) <= 0:
print("Please perform a scan before")
exit(0)
- if not nodes == None:
- fail=False
- for ip in nodes:
- print("Contacting {}...".format(ip),end='')
- try:
- subprocess.run(["ping", "-c", "1", "-W", str(timeout), ip],capture_output=True,check=True)
- nodes.append(ip)
- print()
- except:
- fail=True
- print("=> Not responding!!")
- if not fail:
- print("Success: All nodes are reachable")
- else:
- print("Error: Some of your nodes are not reachable")
+ # Perform ping check
+ fail=False
+ for ip in nodes:
+ print("Contacting {}...".format(ip),end='')
+ try:
+ subprocess.run(["ping", "-c", "1", "-W", str(timeout), ip],capture_output=True,check=True)
+ nodes.append(ip)
+ print()
+ except:
+ fail=True
+ print("=> Not responding!!")
+ if not fail:
+ print("Success: All nodes are reachable")
+ else:
+ print("Error: Some of your nodes are not reachable")
def exec(command):
user="root" if len(CONF["ssh"]["user"]) <= 0 else CONF["ssh"]["user"]