[joker] add simple cli test and arp table support
This commit is contained in:
parent
7ae4a2a05f
commit
d5d6df9b5d
@ -167,14 +167,20 @@ class Node():
|
||||
return (stdout.readlines(), stderr.readlines())
|
||||
|
||||
def __discover__(self):
|
||||
|
||||
|
||||
(data, _) = self.runCommand(
|
||||
"ip link | awk -F: '/^[0-9]+?: eth/ {print $2}' |\
|
||||
sudo xargs -I% arp-scan -l -I % 2>&1 | grep -E '^[0-9]+?\.'")
|
||||
|
||||
"(test -x arp-scan && ip link | awk -F: '/^[0-9]+?: eth/ {print $2}' |\
|
||||
sudo xargs -I% arp-scan -l -I % 2>&1 | grep -E '^[0-9]+?\.';\
|
||||
arp -an | awk -F\" \" '{ gsub(\"[^0-9\\.]\", \"\", $2); printf(\"%s\\t%s\\t%s\\n\", $2, $4, $7)}'\
|
||||
)")
|
||||
|
||||
for line in data:
|
||||
(ip, hwAddr, _) = line.strip().split("\t")
|
||||
self.neighbours.append({"hwAddr": hwAddr, "ip": ip})
|
||||
self.debugLog("%s -> %s" % (self.hostName, ip))
|
||||
|
||||
|
||||
|
||||
|
||||
return self.neighbours
|
||||
|
||||
|
5
joker_test.py
Normal file
5
joker_test.py
Normal file
@ -0,0 +1,5 @@
|
||||
from joker import Joker
|
||||
|
||||
j = Joker(None)
|
||||
j.addNode("localhost", "127.0.0.1", 22, "root", "password")
|
||||
print j.discover()
|
Loading…
x
Reference in New Issue
Block a user