commit
bbf9b3780a
|
@ -2,7 +2,7 @@
|
||||||
"04:11:6b:98:08:21" : {
|
"04:11:6b:98:08:21" : {
|
||||||
"name" : "sellars"
|
"name" : "sellars"
|
||||||
},
|
},
|
||||||
"da:7b:6f:c1:63:d2" : {
|
"00:25:86:e6:f1:bf" : {
|
||||||
"name" : "krtek"
|
"name" : "krtek"
|
||||||
},
|
},
|
||||||
"b0:48:7a:e7:d3:64" : {
|
"b0:48:7a:e7:d3:64" : {
|
||||||
|
@ -12,8 +12,7 @@
|
||||||
"name" : "holstentor"
|
"name" : "holstentor"
|
||||||
},
|
},
|
||||||
"56:47:05:ab:00:2b" : {
|
"56:47:05:ab:00:2b" : {
|
||||||
"name" : "aftermath",
|
"name" : "aftermath"
|
||||||
"group" : 1
|
|
||||||
},
|
},
|
||||||
"ca:96:05:3c:54:f9" : {
|
"ca:96:05:3c:54:f9" : {
|
||||||
"name" : "prometheus"
|
"name" : "prometheus"
|
||||||
|
@ -35,5 +34,8 @@
|
||||||
},
|
},
|
||||||
"ca:a8:ca:2d:c8:b2" : {
|
"ca:a8:ca:2d:c8:b2" : {
|
||||||
"name" : "prometheus"
|
"name" : "prometheus"
|
||||||
|
},
|
||||||
|
"fa:d1:11:80:41:d4" : {
|
||||||
|
"name" : "confusion"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
33
bat2nodes.py
33
bat2nodes.py
|
@ -4,7 +4,7 @@
|
||||||
# Gatewayliste
|
# Gatewayliste
|
||||||
# aliases.json
|
# aliases.json
|
||||||
|
|
||||||
import simplejson as json
|
import json
|
||||||
import fileinput
|
import fileinput
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
@ -128,12 +128,13 @@ if options['aliases']:
|
||||||
if 'group' in alias:
|
if 'group' in alias:
|
||||||
node.group = alias['group']
|
node.group = alias['group']
|
||||||
|
|
||||||
for gateway in options['gateway']:
|
if options['gateway']:
|
||||||
try:
|
for gateway in options['gateway']:
|
||||||
node = maybe_node_by_mac(nodes, (gateway, ))
|
try:
|
||||||
node.group = 2
|
node = maybe_node_by_mac(nodes, (gateway, ))
|
||||||
except:
|
node.group = 2
|
||||||
continue
|
except:
|
||||||
|
continue
|
||||||
|
|
||||||
def map_link(nodes, pair):
|
def map_link(nodes, pair):
|
||||||
distance = 80
|
distance = 80
|
||||||
|
@ -149,16 +150,16 @@ def map_link(nodes, pair):
|
||||||
return link
|
return link
|
||||||
|
|
||||||
|
|
||||||
links = map(lambda x: map_link(nodes, x), links)
|
links = [map_link(nodes, x) for x in links]
|
||||||
|
|
||||||
output = dict()
|
output = dict()
|
||||||
|
|
||||||
output['nodes'] = map(lambda x: {'group': x.group, 'name': x.name,
|
output['nodes'] = [{'group': x.group, 'name': x.name,
|
||||||
'macs': ', '.join(x.macs)
|
'macs': ', '.join(x.macs)
|
||||||
}, nodes)
|
} for x in nodes]
|
||||||
output['links'] = map(lambda x: {'source': x.pair[0], 'target': x.pair[1],
|
output['links'] = [{'source': x.pair[0], 'target': x.pair[1],
|
||||||
'distance': x.distance,
|
'distance': x.distance,
|
||||||
'strength': x.strength
|
'strength': x.strength
|
||||||
}, links)
|
} for x in links]
|
||||||
|
|
||||||
print json.dumps(output)
|
print(json.dumps(output))
|
||||||
|
|
Loading…
Reference in New Issue