Browse Source

add __RAW__ field to node data

The field is not shown in /node/<nodeid>.json but only requestable directly.
It is filled by the datasources with the raw, unfiltered input data.
Helge Jung 9 years ago
parent
commit
a8e35e52ca
4 changed files with 16 additions and 1 deletions
  1. 6 0
      batcave.py
  2. 1 0
      ffstatus/alfred.py
  3. 1 0
      ffstatus/batman.py
  4. 8 1
      ffstatus/server.py

+ 6 - 0
batcave.py

@@ -113,6 +113,12 @@ while True:
 			temp[x]['aliases'] = []
 			temp[x]['clients'] = []
 			temp[x]['neighbours'] = []
+			if not '__RAW__' in temp[x]:
+				temp[x]['__RAW__'] = { }
+			if '__RAW__' in newdata[x]:
+				for key in newdata[x]['__RAW__']:
+					if key in temp[x]['__RAW__']:
+						del(temp[x]['__RAW__'][key])
 		storage.data = dict_merge(temp, newdata)
 		# sanitize each item's data
 		for itemid in storage.data:

+ 1 - 0
ffstatus/alfred.py

@@ -62,6 +62,7 @@ class AlfredParser:
 				'software': {},
 				'statistics': {},
 				'__UPDATED__': { 'alfred': ts, },
+				'__RAW__': { 'alfred': alfredinfo, },
 			}
 			data[myid] = nodeinfo
 

+ 1 - 0
ffstatus/batman.py

@@ -79,6 +79,7 @@ class BatmanParser:
 				'neighbours': neighbours,
 				'clients': [ x for x in item['clients'] ] if 'clients' in item else [],
 				'__UPDATED__': { 'batadv': ts, },
+				'__RAW__': { 'batadv': { itemid: item, } },
 			}
 
 		return data

+ 8 - 1
ffstatus/server.py

@@ -14,6 +14,8 @@ import socket
 from SocketServer import ThreadingMixIn
 import time
 
+import ffstatus
+
 class BatcaveHttpRequestHandler(BaseHTTPRequestHandler):
 	DATAKEY_VPN = '__VPN__'
 	FIELDKEY_UPDATED = '__UPDATED__'
@@ -250,9 +252,14 @@ class BatcaveHttpRequestHandler(BaseHTTPRequestHandler):
 			self.send_error(404, 'No node with id \'' + rawid + '\' present.')
 			return
 
+		# remove fields from output: __RAW__
+		export = ffstatus.dict_merge({}, node)
+		if '__RAW__' in export:
+			del(export['__RAW__'])
+
 		# dump node data as JSON
 		self.send_headers('text/json')
-		self.wfile.write(json.dumps(node))
+		self.wfile.write(json.dumps(export))
 
 	def get_nodestatus(self, rawid):
 		"""Determine node's status."""