Project

General

Profile

« Previous | Next » 

Revision d97375e0

Added by Ohad Levy over 13 years ago

  • ID d97375e0e8ee13cbd1ace39dcbda6f6964d28dcb

Fixes #284 - Use MAC address if IP doesn't exist when tftp booting

  • Uses any of the assoicated mac addresses (RH only) prior to IP
  • Adds a new settings to not update mac or ip information to Foreman - used for cases
    where DHCP booting is done via a temporary dhcp range

View differences:

app/controllers/unattended_controller.rb
:jumpstart_profile, :jumpstart_finish, :pxe_kickstart_config, :pxe_debian_config]
def kickstart
logger.info "#{controller_name}: Kickstart host #{@host.name}"
@dynamic = @host.diskLayout=~/^#Dynamic/
@dynamic = @host.diskLayout =~ /^#Dynamic/
@arch = @host.architecture.name
os = @host.operatingsystem
@osver = os.major.to_i
......
unattended_local "preseed_finish"
end
# this actions is called by each operatingsystem post/finish script - it notify us that the OS installation is done.
# this actions is called by each operatingsystem post/finish script - it notify us that the OS installation is done.
def built
logger.info "#{controller_name}: #{@host.name} is Built!"
@host.built
......
ip = request.env["HTTP_X_FORWARDED_FOR"] unless request.env["HTTP_X_FORWARDED_FOR"].nil?
end
# search for a mac address in any of the RHN provsioning headers
# this section is kickstart only relevant
maclist = []
maccond = "mac in ("
unless request.env['HTTP_X_RHN_PROVISIONING_MAC_0'].nil?
request.env.keys.each { | header |
if header =~ /^HTTP_X_RHN_PROVISIONING_MAC_/ then
maccond << "?, "
maclist << request.env[header].split[1].downcase.strip
begin
request.env.keys.each do | header |
maclist << request.env[header].split[1].downcase.strip if header =~ /^HTTP_X_RHN_PROVISIONING_MAC_/
end
}
rescue => e
logger.info "unknown RHN_PROVISIONING header #{e}"
end
end
maccond.sub!(/, $/, ')')
conditions = (ip and (!maclist.empty?)) ? ["ip = ? and " + maccond, ip, *maclist] : ["ip = ?",ip];
logger.info "#{controller_name}: conditions string: " + conditions.to_s
# we try to match first based on the MAC, falling back to the IP
conditions = (!maclist.empty? ? {:mac => maclist} : {:ip => ip})
@host = Host.find(:first, :include => [:architecture, :media, :operatingsystem, :domain], :conditions => conditions)
if @host.nil?
logger.info "#{controller_name}: unable to find ip/mac match for #{ip}"
......
logger.error "#{controller_name}: #{@host.name}'s operatingsytem [#{@host.operatingsystem.fullname}] has no OS family!"
head(:conflict) and return
end
logger.info "Found #{@host}"
end
def allowed_to_install?
@host.build or @spoof ? true : head(:method_not_allowed)
(@host.build or @spoof) ? true : head(:method_not_allowed)
end
# Cleans Certificate and enable autosign

Also available in: Unified diff