alfred.py: pass firmware version to nodes.json
This commit is contained in:
parent
bd19e5f18c
commit
914836eb9a
|
@ -14,6 +14,12 @@ class alfred:
|
||||||
node_alias = {}
|
node_alias = {}
|
||||||
if 'location' in node:
|
if 'location' in node:
|
||||||
node_alias['gps'] = str(node['location']['latitude']) + ' ' + str(node['location']['longitude'])
|
node_alias['gps'] = str(node['location']['latitude']) + ' ' + str(node['location']['longitude'])
|
||||||
|
|
||||||
|
try:
|
||||||
|
node_alias['firmware'] = node['software']['firmware']['release']
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
if 'hostname' in node:
|
if 'hostname' in node:
|
||||||
node_alias['name'] = node['hostname']
|
node_alias['name'] = node['hostname']
|
||||||
elif 'name' in node:
|
elif 'name' in node:
|
||||||
|
|
|
@ -15,6 +15,7 @@ class D3MapBuilder:
|
||||||
output['nodes'] = [{'name': x.name, 'id': x.id,
|
output['nodes'] = [{'name': x.name, 'id': x.id,
|
||||||
'macs': ', '.join(x.macs),
|
'macs': ', '.join(x.macs),
|
||||||
'geo': [float(x) for x in x.gps.split(" ")] if x.gps else None,
|
'geo': [float(x) for x in x.gps.split(" ")] if x.gps else None,
|
||||||
|
'firmware': x.firmware,
|
||||||
'flags': x.flags
|
'flags': x.flags
|
||||||
} for x in nodes]
|
} for x in nodes]
|
||||||
|
|
||||||
|
|
1
node.py
1
node.py
|
@ -10,6 +10,7 @@ class Node():
|
||||||
"client": False
|
"client": False
|
||||||
})
|
})
|
||||||
self.gps = None
|
self.gps = None
|
||||||
|
self.firmware = None
|
||||||
|
|
||||||
def add_mac(self, mac):
|
def add_mac(self, mac):
|
||||||
mac = mac.lower()
|
mac = mac.lower()
|
||||||
|
|
|
@ -185,6 +185,9 @@ class NodeDB:
|
||||||
if 'gps' in alias:
|
if 'gps' in alias:
|
||||||
node.gps = alias['gps']
|
node.gps = alias['gps']
|
||||||
|
|
||||||
|
if 'firmware' in alias:
|
||||||
|
node.firmware = alias['firmware']
|
||||||
|
|
||||||
# list of macs
|
# list of macs
|
||||||
# if options['gateway']:
|
# if options['gateway']:
|
||||||
# mark_gateways(options['gateway'])
|
# mark_gateways(options['gateway'])
|
||||||
|
|
Loading…
Reference in a new issue