openwisp-controller
openwisp-controller copied to clipboard
[feature] Creation of Fuzzy Locations
- Addition of new
is_fuzzyfield (or anything similar) to location model - Implement new celery task to fetch location details from geoip2 and create/update location based on the details.
- Either integrate the above task into the task created in #1033 or chain them together.
Scenarios to handle:
- When a device has last_ip having no WHOIS record, then the WHOIS record should be created and a new location should be created for the device. The location must be updated with latest coordinates when last_ip of device is updated.
- When a device (A) has last_ip, which has WHOIS record, then the location of existing device (B) of same ip should be attached to device A, if:
- A either has no location or A's location is estimated. If either fails, then location should be created/updated using coordinates from WHOIS record
- there is only one existing device with location. In case there are multiple devices with same last_ip and they have locations then a notification must be sent to user notifying them for the same and asking them to resolve this manually. In case A has a location which is estimated then it should be deleted before attaching an already existing location.
- If two devices A and B have same last_ip which implies they are attached to same location then if either device updates their last_ip (suppose A does) then A should have a new location created with the coordinates for the latest last_ip.
Following are the items which I think we can discuss before implementing this to have more clarity:
- Should we have one task for both WHOIS record creation and fuzzy location creation or have separate tasks for both? Having one task leads to less flexibility as If one part (e.g., fuzzy location) fails, the whole task will fail or even if we have separate transaction blocks, it will be difficult to debug. As mentioned, I am thinking of chaining them.
- If keeping separate tasks, should we add a retry mechanism?