netjsonconfig icon indicating copy to clipboard operation
netjsonconfig copied to clipboard

[WIP][backward-conversion] Recognize templates #100

Open atb00ker opened this issue 5 years ago • 2 comments

Usage


temp1 = {
  "general": { "hostname": "device.example.com" }
}
# This dance of rendering the json is done to 
# remove all the keys with no value from json.
# Such keys are not desirable because they cause 
# some lists to appear not similar which may cause 
# data duplication
ren1 = OpenWrt(temp1).render()
native1 = OpenWrt(native=ren1)
temp1 = native1.json()

test = OpenWrt(native=open("device.example.com.tar.gz"))
print(test.distinct_native([temp1]))

Todo

  • [ ] Testing
  • [ ] Automated Testing
  • [ ] Documentation

Questions

  1. If someone sets some information, say, an interface in a template and apply it to the device and later remove that interface from luci, It will be resend by the controller and appear again on the device because it still exists in the template. How should be promote users from removing information from just their devices?

  2. In an array like section, say interfaces, if only one value of a member, say mtu of interface is changed, do I copy the entire interface or just the mtu value with interface name? Currently copying the entire thing because I feel it should be stored together. (Same for "radios" section)

Closes #100

atb00ker avatar Apr 20 '20 09:04 atb00ker

Coverage Status

Coverage decreased (-1.7%) to 98.198% when pulling 57856c63edf14526e2454165f575e0f9437d70bd on atb00ker:duplicate-check into cadb36b496e2b0433d45270a505d9916a6d11699 on openwisp:master.

coveralls avatar Apr 20 '20 09:04 coveralls

@nemesisdesign sorry, I read it and I haven't explained it enough. Basically, consider the case:

  1. User adds an interface in a template and adds the template in a device
  2. controller sends the interface to device and it gets added successfully.
  3. User deletes the interface from device (say by using ssh or luci)
  4. The new implementation of device sync in https://github.com/openwisp/netjsonconfig/pull/152 & openwisp-config would send the device information to controller
  5. controller compares the two configurations from device and controller.
  6. Sometime later, the controller will send the deleted interface again to the device and the user will be irritated by seeing the deleted interface and added.

Hence, I think for https://github.com/openwisp/netjsonconfig/issues/100 we need to consider this case as well.

I hope I am able to explain the problem now.

atb00ker avatar Jul 13 '20 18:07 atb00ker