summaryrefslogtreecommitdiff
path: root/clusterman/commands/node.py
blob: bd7c44354aa8a3bc48fc87c13de695a8168161f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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("")