Revision f23483a2
Added by Johannes Scheuermann over 9 years ago
app/models/concerns/orchestration/tftp.rb | ||
---|---|---|
return if Rails.env == "test"
|
||
if host.configTemplate({:kind => host.operatingsystem.template_kind}).nil? && host.configTemplate({:kind => "iPXE"}).nil?
|
||
failure _("No %{template_kind} templates were found for this host, make sure you define at least one in your %{os} settings") %
|
||
{ :template_kind => host.operatingsystem.template_kind, :os => host.os }
|
||
{ :template_kind => host.operatingsystem.template_kind, :os => host.operatingsystem }
|
||
end
|
||
end
|
||
|
||
def generate_pxe_template
|
||
# this is the only place we generate a template not via a web request
|
||
# therefore some workaround is required to "render" the template.
|
||
@kernel = host.os.kernel(host.arch)
|
||
@initrd = host.os.initrd(host.arch)
|
||
@kernel = host.operatingsystem.kernel(host.arch)
|
||
@initrd = host.operatingsystem.initrd(host.arch)
|
||
# work around for ensuring that people can use @host as well, as tftp templates were usually confusing.
|
||
@host = self.host
|
||
if build?
|
||
pxe_render host.configTemplate({:kind => host.os.template_kind})
|
||
pxe_render host.configTemplate({:kind => host.operatingsystem.template_kind})
|
||
else
|
||
if host.os.template_kind == "PXEGrub"
|
||
if host.operatingsystem.template_kind == "PXEGrub"
|
||
pxe_render ConfigTemplate.find_by_name("PXEGrub default local boot")
|
||
else
|
||
pxe_render ConfigTemplate.find_by_name("PXELinux default local boot")
|
||
end
|
||
end
|
||
rescue => e
|
||
failure _("Failed to generate %{template_kind} template: %{e}") % { :template_kind => host.os.template_kind, :e => e }
|
||
failure _("Failed to generate %{template_kind} template: %{e}") % { :template_kind => host.operatingsystem.template_kind, :e => e }
|
||
end
|
||
|
||
def queue_tftp
|
||
... | ... | |
# medium or arch changed
|
||
set_tftp = true if old.host.medium.try(:id) != host.medium.try(:id) or old.host.arch.try(:id) != host.arch.try(:id)
|
||
# operating system changed
|
||
set_tftp = true if host.os and old.host.os and (old.host.os.name != host.os.name or old.host.os.try(:id) != host.os.try(:id))
|
||
set_tftp = true if host.operatingsystem and old.host.operatingsystem and (old.host.operatingsystem.name != host.operatingsystem.name or old.host.operatingsystem.try(:id) != host.operatingsystem.try(:id))
|
||
# MAC address changed
|
||
if mac != old.mac
|
||
set_tftp = true
|
Also available in: Unified diff
fixes #9397 - Make usage of @host.operatingsystem in UnattendedController consistent
Changed all host.os to host.operatingsystem