Created
February 26, 2014 00:23
-
-
Save treydock/9220870 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/share/foreman/script/rails runner -e production | |
Host.all.each do |host| | |
next unless host.dhcp? | |
print "#{host}..." | |
dhcp_record = host.dhcp_record | |
print "#{dhcp_record}..." | |
if dhcp_record.valid? | |
puts "VALID" | |
elsif dhcp_record.conflicting? | |
puts "CONFLICT" | |
warn "not going to do anything as we found conflicting dhcp records" | |
warn "we wanted #{dhcp_record.attrs.inspect} but found: #{dhcp_record.conflicts.map{|c| c.attrs.inspect}.join(', ')}" | |
else | |
print "missing..recreating.." | |
dhcp_record.create | |
puts "DONE" | |
end | |
host.interfaces.each do |interface| | |
next unless interface.dhcp? | |
print "#{interface}..." | |
dhcp_record = interface.dhcp_record | |
print "#{dhcp_record}..." | |
if dhcp_record.valid? | |
puts "VALID" | |
elsif dhcp_record.conflicting? | |
puts "CONFLICT" | |
warn "not going to do anything as we found conflicting dhcp records" | |
warn "we wanted #{dhcp_record.attrs.inspect} but found: #{dhcp_record.conflicts.map{|c| c.attrs.inspect}.join(', ')}" | |
else | |
print "missing..recreating.." | |
dhcp_record.create | |
puts "DONE" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment