Recovering Lost DHCP reservations


Someone asked me today on IRC how to recover his dhcp reservations, as he was using foreman to create those, and his dhcp server died.

Since we are slow on delivering  #944, here is a short snippet that would get the job done.

This script validates all DHCP records, if one is missing, it would recreate it.

if you are using 0.5 or newer, simply change the shebang line to be something like:

#!/usr/bin/env /usr/share/foreman/script/rails runner -e production

What about conflicting records? 

In the case of a conflict, its possible to do remove the conflicting reservations and simply recreate the correct one.. however, you should be sure you can remove the old ones before..

dhcp_record.conflicts(&:destroy)
dhcp_record.create

Comments from the community:


Foreman 3.10.0 has been released! Follow the quick start to install it.

Foreman 3.9.1 has been released! Follow the quick start to install it.