|
@@ -72,6 +72,14 @@ class BaseStorage(object):
|
|
|
"""
|
|
|
pass
|
|
|
|
|
|
+ def set_node_data(self, node_id, data):
|
|
|
+ """
|
|
|
+ Sets the node's data.
|
|
|
+ This method should be overriden in a subclass,
|
|
|
+ but still call the parent one.
|
|
|
+ """
|
|
|
+ self.__data[node_id] = data
|
|
|
+
|
|
|
@property
|
|
|
def status(self):
|
|
|
"""Gets status information on the storage."""
|
|
@@ -132,7 +140,16 @@ class BaseStorage(object):
|
|
|
del current[item_id]['__RAW__'][key]
|
|
|
|
|
|
# merge the dictionaries
|
|
|
- updated = ffstatus.dict_merge(current, newdata)
|
|
|
+ updated = {}
|
|
|
+ for itemid in newdata:
|
|
|
+ if not itemid in current:
|
|
|
+ # new element which did not exist in storage before, that's easy
|
|
|
+ updated[itemid] = newdata[itemid]
|
|
|
+ continue
|
|
|
+
|
|
|
+ # merge the old and new element
|
|
|
+ update = ffstatus.dict_merge(current[itemid], newdata[itemid])
|
|
|
+ updated[itemid] = update
|
|
|
|
|
|
# sanitize each item's data
|
|
|
for itemid in updated:
|
|
@@ -153,10 +170,10 @@ class BaseStorage(object):
|
|
|
clients.remove(mac)
|
|
|
|
|
|
# set clientcount
|
|
|
- updated[itemid]['clientcount'] = len(clients)
|
|
|
+ item['clientcount'] = len(clients)
|
|
|
|
|
|
- # set the new data
|
|
|
- self.__data = updated
|
|
|
+ # finally, set each new data
|
|
|
+ self.set_node_data(itemid, item)
|
|
|
|
|
|
def get_nodes(self, sortby=None, include_raw_data=False):
|
|
|
"""Gets a list of all known nodes."""
|