There's no documentation on how to accomplish that yet, but we will help you out. If you do accomplish it and will want to share your solution I believe it will be beneficial to the community.
As first thing, I suggest you to implement this in development mode (not on your instance). Creating a new django app in which you add a new model, eg: DeviceIp, in which you add a ForeignKey field pointing to Device and a ForeignKey pointing to Device, the two fields should be flagged as unique_together (look all these terms on the django documentation). Then add a signal receiver function in this new app which listens to save events on Device, return if the "created" parameter is False so that you act only on created devices, and in this function you add the logic to write to the context field of the Device. There should be a method in django-ipam to get the first available ip from a subnet. Then you should decide also how to manage subnets, if all devices are on the same subnet is easy, otherwise you should probably have a way to tell the system to which subnet the device pertains to. Thanks Federico On Wed, Feb 5, 2020 at 10:23 PM João Henrique Albuquerque < [email protected]> wrote: > Thanks for the pointers, Oliver. > > I'll look into it later > > Em qua., 5 de fev. de 2020 às 17:39, Oliver Kraitschy <[email protected]> > escreveu: > >> On Wed, Feb 05, 2020 at 05:15:43PM -0300, João Henrique Albuquerque wrote: >> > >> > About the signal on device creation, I should probably do it under the >> DB >> > I'm using, right? >> > E.g, when a new entry is made to the config_device tables update the >> field >> > with context straight to the backend of the application. >> >> https://docs.djangoproject.com/en/3.0/ref/signals/#post-save >> >> That signal is emitted if an instance of a model class has been saved. You >> can then check if it was an instance of the Device model class and if yes, >> determine the ip to use and fill the device context accordingly. >> >> Greetings, >> Oliver >> >> -- >> You received this message because you are subscribed to the Google Groups >> "OpenWISP" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web, visit >> https://groups.google.com/d/msgid/openwisp/20200205203901.GA7980%40idefix >> . >> > -- > You received this message because you are subscribed to the Google Groups > "OpenWISP" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web, visit > https://groups.google.com/d/msgid/openwisp/CAO5jQiZqrFJh%2BjnEcDahzUTvvtiC_XR8g%3D01ej3GYo7_51O3RA%40mail.gmail.com > <https://groups.google.com/d/msgid/openwisp/CAO5jQiZqrFJh%2BjnEcDahzUTvvtiC_XR8g%3D01ej3GYo7_51O3RA%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "OpenWISP" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web, visit https://groups.google.com/d/msgid/openwisp/CAERYH6XM1fwAySmzyfU40Fjov6-QKeYZkJn2NBWZzB5qzgaU4g%40mail.gmail.com.
