Browse Source

batman: set MAC address of legacy nodes (i.e. gateways)

Helge Jung 9 years ago
parent
commit
5222415fc8
1 changed files with 7 additions and 4 deletions
  1. 7 4
      ffstatus/batman.py

+ 7 - 4
ffstatus/batman.py

@@ -84,16 +84,14 @@ class BatmanParser:
 
         # parse vis data
         for item in visdata:
-            itemid = ffstatus.mac2id(item.get('primary', item.get('router')))
+            itemmac = item.get('primary', item.get('router'))
+            itemid = ffstatus.mac2id(itemmac)
             content = {
                 'aliases': [],
                 'neighbours': {},
                 '__UPDATED__': {'batctl': timestamp},
             }
 
-            if itemid in gateways:
-                content['type'] = 'gateway'
-
             neigh_id = ffstatus.mac2id(item.get('neighbor'))
             if neigh_id is not None:
                 neigh_q = item.get('label', '0')
@@ -113,6 +111,11 @@ class BatmanParser:
 
                 itemid = ofid
                 content['aliases'].append(secid)
+            else:
+                if not 'mac' in content:
+                    content['mac'] = itemmac
+                if itemid in gateways:
+                    content['type'] = 'gateway'
 
             if itemid in data:
                 data[itemid] = ffstatus.dict_merge(