On Mon, Jan 8, 2018 at 12:48 PM, Kasper Laudrup <[email protected]> wrote:
> Hi fellow Django users, > > I'm working on creating a Django application for managing DHCP leases and > DNS entries and for that I would like to be able to (re)start the DHCP > daemon from Djano. > > I think it would be best to simply use a popen object from pythons > subprocess module (most likely wrapped in a class), but I'm not really sure > which place would be the most logical place to keep that object? Of course > there should only be a single instance of that object. > > I have also been looking into using some kind of service framework, but > what I have found so far seems to be aimed at task queues (celery etc.), > which would definitely be an overkill for my use case. > > It could also be that I'm approaching this the wrong way, in which case I > would be happy to hear better ideas on how to do this. > > Thanks a lot for any input. > > Kind regards, > > Kasper Laudrup > With this https://stackoverflow.com/questions/89228/calling-an-external-command-in-python you can find out which distribution is using, then for each distribution there's a different command for restarting DHCP (systemctl, upstart, system-v) and with the same execute it with sudo to some user with privileges to just do that. You can call that function ("restart_dhcp()") from any django view. HTH > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit https://groups.google.com/d/ms > gid/django-users/f86f877c-3462-b8bd-95ac-3da1c77c8f72%40stacktrace.dk. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BFDnh%2Bpzu%3DE2yKHEkcPZhj8X3nA-29pwRfTo%3DSqk%2BOmjQUxkw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

