Project

General

Profile

« Previous | Next » 

Revision f23483a2

Added by Johannes Scheuermann over 9 years ago

fixes #9397 - Make usage of @host.operatingsystem in UnattendedController consistent

Changed all host.os to host.operatingsystem

View differences:

app/controllers/unattended_controller.rb
def load_template_vars
# load the os family default variables
send "#{@host.os.pxe_type}_attributes"
send "#{@host.operatingsystem.pxe_type}_attributes"
@provisioning_type = @host.is_a?(Hostgroup) ? 'hostgroup' : 'host'
......
end
def alterator_attributes
os = @host.operatingsystem
@mediapath = os.mediumpath @host
@mediapath = @host.operatingsystem.mediumpath @host
@mediaserver = URI(@mediapath).host
@metadata = params[:metadata].to_s
end
......
if @host.operatingsystem.supports_image and @host.use_image
@install_type = "flash_install"
# We have an individual override for the host's image file
if @host.image_file
@archive_location = @host.image_file
else
@archive_location = @host.default_image_file
end
@archive_location = @host.image_file ? @host.image_file : @host.default_image_file
else
@install_type = "initial_install"
@system_type = "standalone"
......
def kickstart_attributes
@dynamic = @host.diskLayout =~ /^#Dynamic/
@arch = @host.architecture.name
os = @host.operatingsystem
@osver = os.major.to_i
@mediapath = os.mediumpath @host
@repos = os.repos @host
@osver = @host.operatingsystem.major.to_i
@mediapath = @host.operatingsystem.mediumpath @host
@repos = @host.operatingsystem.repos @host
end
def preseed_attributes
@preseed_path = @host.os.preseed_path @host
@preseed_server = @host.os.preseed_server @host
@preseed_path = @host.operatingsystem.preseed_path @host
@preseed_server = @host.operatingsystem.preseed_server @host
end
def yast_attributes
......
end
def aif_attributes
os = @host.operatingsystem
@mediapath = os.mediumpath @host
@mediapath = @host.operatingsystem.mediumpath @host
end
def memdisk_attributes
os = @host.operatingsystem
@mediapath = os.mediumpath @host
@mediapath = @host.operatingsystem.mediumpath @host
end
def ZTP_attributes
os = @host.operatingsystem
@mediapath = os.mediumpath @host
@mediapath = @host.operatingsystem.mediumpath @host
end
def waik_attributes
app/helpers/hosts_helper.rb
[_("MAC Address"), host.mac],
[_("Puppet Environment"), (link_to(host.environment, hosts_path(:search => "environment = #{host.environment}")) if host.environment)],
[_("Host Architecture"), (link_to(host.arch, hosts_path(:search => "architecture = #{host.arch}")) if host.arch)],
[_("Operating System"), (link_to(host.os.to_label, hosts_path(:search => "os_description = #{host.os.description}")) if host.os)],
[_("Operating System"), (link_to(host.operatingsystem.to_label, hosts_path(:search => "os_description = #{host.operatingsystem.description}")) if host.operatingsystem)],
[_("Host group"), (link_to(host.hostgroup, hosts_path(:search => %{hostgroup_title = "#{host.hostgroup}"})) if host.hostgroup)],
]
fields += [[_("Location"), (link_to(host.location.title, hosts_path(:search => "location = #{host.location}")) if host.location)]] if SETTINGS[:locations_enabled]
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
app/models/nic/bootable.rb
})
# Are we booting SPARC solaris?
if host.jumpstart?
jumpstart_arguments = host.os.jumpstart_params host, host.model.vendor_class
jumpstart_arguments = host.operatingsystem.jumpstart_params host, host.model.vendor_class
attrs.merge! jumpstart_arguments unless jumpstart_arguments.empty?
end
attrs
app/models/operatingsystem.rb
def medium_uri(host, url = nil)
url ||= host.medium.path
medium_vars_to_uri(url, host.architecture.name, host.os)
medium_vars_to_uri(url, host.architecture.name, host.operatingsystem)
end
def medium_vars_to_uri(url, arch, os)
app/views/hosts/_assign_hosts.html.erb
</td>
<td><%= name_column(host) %>
</td>
<td class="hidden-xs"><%= (icon(host.os, :size => "18x18") + trunc_with_tooltip(" #{host.os.to_label}",14)).html_safe if host.os %></td>
<td class="hidden-xs"><%= (icon(host.operatingsystem, :size => "18x18") + trunc_with_tooltip(" #{host.operatingsystem.to_label}",14)).html_safe if host.operatingsystem %></td>
<td class="hidden-xs"><%= trunc_with_tooltip(host.try(:environment), 14) %></td>
<td class="hidden-tablet hidden-xs"><%= model_name host %></td>
<td class="hidden-tablet hidden-xs"><%= label_with_link host.hostgroup, 26 %></td>
app/views/hosts/_list.html.erb
</td>
<td class='ellipsis'><%= name_column(host) %>
</td>
<td class="hidden-xs"><%= (icon(host.os, :size => "18x18") + trunc_with_tooltip(" #{host.os.to_label}",14)).html_safe if host.os %></td>
<td class="hidden-xs"><%= (icon(host.operatingsystem, :size => "18x18") + trunc_with_tooltip(" #{host.operatingsystem.to_label}",14)).html_safe if host.operatingsystem %></td>
<td class="hidden-xs"><%= trunc_with_tooltip(host.try(:environment), 14) %></td>
<td class="hidden-tablet hidden-xs ellipsis"><%= model_name host %></td>
<td class="hidden-tablet hidden-xs ellipsis"><%= label_with_link host.hostgroup, 26, @hostgroup_authorizer %></td>
app/views/hosts/show.html.erb
<% javascript 'charts', 'hosts' %>
<% title @host.to_label, icon(@host.os) + @host.to_label %>
<% title @host.to_label, icon(@host.operatingsystem) + @host.to_label %>
<%= host_title_actions(@host) %>
<% content_for(:search_bar) {reports_show} %>
<div id="host-show" class="row" data-history-url='<%= host_path(@host)%>'>
app/views/unattended/snippets/_epel.erb
''
end
-%>
su -c 'rpm -Uvh <%= @host.os.medium_uri(@host, epel_url) %>'
su -c 'rpm -Uvh <%= @host.operatingsystem.medium_uri(@host, epel_url) %>'
test/unit/medium_test.rb
host = FactoryGirl.create(:host, :with_operatingsystem)
refute host.build?
host.medium = medium
host.os.media << medium
host.operatingsystem.media << medium
assert host.save!
medium.hosts << host
......
host = FactoryGirl.create(:host, :with_operatingsystem)
host.build = true
host.medium = medium
host.os.media << medium
host.operatingsystem.media << medium
assert host.save!
medium.hosts << host
test/unit/operatingsystem_test.rb
assert operating_system.save
host = FactoryGirl.create(:host)
host.os = operating_system
host.operatingsystem = operating_system
host.save(:validate => false)
assert !operating_system.destroy
test/unit/operatingsystems/operatingsystems_test.rb
:ptables => [ptables(:one)],
:media => [FactoryGirl.build(:medium)]),
:architecture => arch)
assert_equal(config['expected'], host.os.kernel(host.arch))
assert_equal(config['expected'], host.operatingsystem.kernel(host.arch))
end
end
......
:ptables => [ptables(:one)],
:media => [FactoryGirl.build(:medium)]),
:architecture => arch)
assert_equal(config['expected'], host.os.initrd(host.arch))
assert_equal(config['expected'], host.operatingsystem.initrd(host.arch))
end
end
......
:ptables => [ptables(:one)],
:media => [FactoryGirl.build(:medium)]),
:architecture => arch)
assert_equal(config['expected'], host.os.pxe_prefix(host.arch))
assert_equal(config['expected'], host.operatingsystem.pxe_prefix(host.arch))
end
end
......
:architecture => arch,
:medium => medium)
host.medium.operatingsystems << host.os
host.arch.operatingsystems << host.os
host.medium.operatingsystems << host.operatingsystem
host.arch.operatingsystems << host.operatingsystem
prefix = host.os.pxe_prefix(host.arch).to_sym
pxe_files = host.os.pxe_files(host.medium, host.arch)
prefix = host.operatingsystem.pxe_prefix(host.arch).to_sym
pxe_files = host.operatingsystem.pxe_files(host.medium, host.arch)
assert pxe_files.include?({ prefix => config['kernel'] })
assert pxe_files.include?({ prefix => config['initrd'] })

Also available in: Unified diff