Fix last_reachable timestamp bug
Change-Id: I0d479c9aef59866db164790247eca2c3c6e1f0bf
diff --git a/roc.py b/roc.py
index fe328aa..be609bf 100644
--- a/roc.py
+++ b/roc.py
@@ -9,6 +9,7 @@
from requests.structures import CaseInsensitiveDict
import logging as log
import pyaml
+from datetime import datetime
from device import Device
@@ -120,10 +121,17 @@
return devices
def update_devices(self, devices):
+ new = {}
dgs = self.get_devicegroups()
for dg in dgs:
for d in dg['imsis']:
- devices[str(d['imsi-range-from'])] = Device(str(d['imsi-id']), d['imsi-range-from'])
+ imsi_id = str(d['imsi-id'])
+ imsi = str(d['imsi-range-from'])
+ last_reachable = datetime.min
+ if imsi_id in devices:
+ last_reachable = devices[imsi_id].last_reachable
+ new[imsi_id] = Device(imsi_id, imsi, last_reachable)
+ return new
def get_subnet(self):
subnets = {}