From 77ea2f3ee6968d25a2e63e8c78c6bb53ff8a6d00 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Thu, 26 Oct 2023 11:51:46 +0200 Subject: [PATCH] Minor changes --- clusterman/__main__.py | 2 +- clusterman/commands/node.py | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/clusterman/__main__.py b/clusterman/__main__.py index 56c9f60..706a288 100644 --- a/clusterman/__main__.py +++ b/clusterman/__main__.py @@ -18,7 +18,7 @@ def main(): # Run the proper handler if args.command == "node": print("Do node related stuff") - + node.scan("10.0.0.1","10.0.0.10") if args.command == "frontend": print("Do frontend related stuff") diff --git a/clusterman/commands/node.py b/clusterman/commands/node.py index 7844301..bd7c443 100644 --- a/clusterman/commands/node.py +++ b/clusterman/commands/node.py @@ -1,6 +1,26 @@ - +import os def ls(): print("List nodes..") + + +def scan(ip4_from,ip4_to,timeout=0.1): + from_split=[int(n) for n in ip4_from.split(".")] + to_split=[int(n) for n in ip4_to.split(".")] + nodes=list() + print("----- Starting node scan (timeout={}s) -----".format(timeout)) + for W in range(from_split[0],to_split[0]+1): + for X in range(from_split[1],to_split[1]+1): + for Y in range(from_split[2],to_split[2]+1): + for Z in range(from_split[3],to_split[3]+1): + ip="{}.{}.{}.{}".format(W,X,Y,Z) + response = os.system("ping -c 1 -W " + str(timeout)+ " " + ip + " &>/dev/null") + print("Contacting {}...".format(ip),end='') + if response==0: + nodes.append() + print("=> Found!!") + else: + print("") +