diff options
author | root <root@freifunk.in-kiel.de> | 2014-06-05 14:03:20 +0200 |
---|---|---|
committer | root <root@freifunk.in-kiel.de> | 2014-06-05 14:03:20 +0200 |
commit | 8b3bde6b7a5339da2ee4473fe2fa3b7d3159bb17 (patch) | |
tree | b3405d595babcb4cb1b3f935b6269859e9df868f | |
parent | d12befa56f1830ba9e18952021e4255237d612fb (diff) | |
parent | f18d0b38a915cc79a6efe147cf498329d9882461 (diff) |
Merge remote-tracking branch 'ffnord/master'
Conflicts:
.gitignore
-rw-r--r-- | alfred.py | 7 | ||||
-rwxr-xr-x | bat2nodes.py | 2 | ||||
-rwxr-xr-x | batman.py | 2 | ||||
-rw-r--r-- | nodedb.py | 19 |
4 files changed, 22 insertions, 8 deletions
@@ -23,6 +23,11 @@ class alfred: except KeyError: pass + try: + node_alias['id'] = node['network']['mac'] + except KeyError: + pass + if 'hostname' in node: node_alias['name'] = node['hostname'] elif 'name' in node: @@ -33,5 +38,5 @@ class alfred: if __name__ == "__main__": ad = alfred() - al = ad.alias() + al = ad.aliases() print(al) diff --git a/bat2nodes.py b/bat2nodes.py index eee2289..7119464 100755 --- a/bat2nodes.py +++ b/bat2nodes.py @@ -49,7 +49,7 @@ if options['mesh']: bm = batman(mesh_interface) db.parse_vis_data(bm.vis_data(options['alfred'])) for gw in bm.gateway_list(): - db.mark_gateways(gw.mac) + db.mark_gateways(gw['mac']) else: bm = batman() db.parse_vis_data(bm.vis_data(options['alfred'])) @@ -60,6 +60,8 @@ class batman: gw.append({'mac': own_mac, 'bandwidth': gw_mode['bandwidth']}) for line in lines: gw_line = line.split() + if (gw_line[0] == 'No'): + continue # When in client gateway mode maybe gw_line[0] is not the right. gw.append({'mac':gw_line[0], 'bandwidth': gw_line[-1]}) return gw @@ -169,17 +169,20 @@ class NodeDB: def import_aliases(self, aliases): for mac, alias in aliases.items(): try: - node = self.maybe_node_by_fuzzy_mac(mac) + node = self.maybe_node_by_mac([mac]) except: - # create an offline node - node = Node() - node.add_mac(mac) - self._nodes.append(node) + try: + node = self.maybe_node_by_fuzzy_mac(mac) + except: + # create an offline node + node = Node() + node.add_mac(mac) + self._nodes.append(node) if 'name' in alias: node.name = alias['name'] - if 'vpn' in alias and alias['vpn']: + if 'vpn' in alias and alias['vpn'] and mac and node.interfaces and mac in node.interfaces: node.interfaces[mac].vpn = True if 'gps' in alias: @@ -188,6 +191,9 @@ class NodeDB: if 'firmware' in alias: node.firmware = alias['firmware'] + if 'id' in alias: + node.id = alias['id'] + # list of macs # if options['gateway']: # mark_gateways(options['gateway']) @@ -196,6 +202,7 @@ class NodeDB: try: node = self.maybe_node_by_mac((gateway, )) except: + print("WARNING: did not find gateway '",gateway,"' in node list") continue node.flags['gateway'] = True |