Skip to content

Commit

Permalink
Updates for 1.12 compatibility
Browse files Browse the repository at this point in the history
Removes Spacewalk functionality, the form was the mess.
  • Loading branch information
domcleal committed Jul 1, 2016
1 parent 3c02ae5 commit 23cd8ca
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 69 deletions.
Binary file removed app/assets/images/foreman_setup/false.png
Binary file not shown.
30 changes: 1 addition & 29 deletions app/controllers/foreman_setup/provisioners_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module ForemanSetup
class ProvisionersController < ::ApplicationController
include Foreman::Controller::ProvisioningTemplates
include Foreman::Renderer

before_filter :find_myself, :only => [:new, :create]
Expand Down Expand Up @@ -98,45 +99,16 @@ def step4

@provisioner.hostgroup.medium ||= @provisioner.host.os.media.first
@medium = Medium.new(params['foreman_setup_provisioner'].try(:[], 'medium_attributes'))

parameters = @provisioner.hostgroup.group_parameters
@activation_key = parameters.where(:name => 'activation_key').first || parameters.new(:name => 'activation_key')
@satellite_type = parameters.where(:name => 'satellite_type').first || parameters.new(:name => 'satellite_type')
end

def step4_update
if params['medium_type'] == 'spacewalk'
spacewalk_hostname = params['spacewalk_hostname']
if spacewalk_hostname.blank?
@provisioner.errors.add(:base, _("Spacewalk hostname is missing"))
process_error :render => 'foreman_setup/provisioners/step4', :object => @provisioner, :redirect => step4_foreman_setup_provisioner_path
return
end
end

medium_id = params['foreman_setup_provisioner']['hostgroup_attributes']['medium_id']
if medium_id.to_i > 0
@medium = Medium.find(medium_id) || raise('unable to find medium')
else
@provisioner.hostgroup.medium_id = nil
@medium = Medium.new(params['foreman_setup_provisioner']['create_medium'].slice(:name, :path))
end
@medium.path = "http://#{spacewalk_hostname}/ks/dist/ks-rhel-$arch-server-$major-$version" unless spacewalk_hostname.blank?

parameters = @provisioner.hostgroup.group_parameters
@activation_key = parameters.where(:name => 'activation_key').first
if @activation_key
@activation_key.assign_attributes(params['foreman_setup_provisioner']['activation_key'])
elsif params['foreman_setup_provisioner']['activation_key']['value'].present?
@activation_key = parameters.new(params['foreman_setup_provisioner']['activation_key'].merge(:name => 'activation_key'))
end

@satellite_type = parameters.where(:name => 'satellite_type').first
if @satellite_type
@satellite_type.assign_attributes(params['foreman_setup_provisioner']['satellite_type'])
elsif params['foreman_setup_provisioner']['satellite_type']['value'].present?
@satellite_type = parameters.new(params['foreman_setup_provisioner']['satellite_type'].merge(:name => 'satellite_type'))
end

# Associate medium with the host OS
@medium.os_family ||= @provisioner.host.os.type
Expand Down
12 changes: 6 additions & 6 deletions app/views/foreman_setup/provisioners/_step1.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@
<div>
<%= f.hidden_field :host_id %>
<% if f.object.host.present? %>
<%= checked_icon f.object.host.present? %> <%= _("Found registered host %s") % f.object.host.name %>
<%= icon_text 'ok', _("Found registered host %s") % f.object.host.name, :kind => 'pficon' %>
<% else %>
<%= image_tag 'foreman_setup/false.png' %> <%= _("Missing registered host %s, please ensure it is checking in") % f.object.fqdn %>
<%= icon_text 'error-circle-o', _("Missing registered host %s, please ensure it is checking in") % f.object.fqdn, :kind => 'pficon' %>
<% end %>
</div>
<div>
<%= f.hidden_field :smart_proxy_id %>
<% if f.object.smart_proxy.present? %>
<%= checked_icon f.object.smart_proxy.present? %> <%= _("Found registered smart proxy %s") % f.object.smart_proxy.name %>
<%= icon_text 'ok', _("Found registered smart proxy %s") % f.object.smart_proxy.name, :kind => 'pficon' %>
<% else %>
<%= image_tag 'foreman_setup/false.png' %> <%= _("Missing registered smart proxy %s, please ensure it is registered") % f.object.fqdn %>
<%= icon_text 'error-circle-o', _("Missing registered smart proxy %s, please ensure it is registered") % f.object.fqdn, :kind => 'pficon' %>
<% end %>
</div>
<div>
<% if f.object.host.present? && f.object.interfaces.any? %>
<%= checked_icon f.object.host.present? %> <%= _("Host %s has at least one network interface") % f.object.host.name %>
<%= icon_text 'ok', _("Host %s has at least one network interface") % f.object.host.name, :kind => 'pficon' %>
<% else %>
<%= image_tag 'foreman_setup/false.png' %> <%= _("No network interfaces listed in $interfaces fact") %>
<%= icon_text 'error-circle-o', _("No network interfaces listed in $interfaces fact"), :kind => 'pficon' %>
<% end %>
</div>

Expand Down
24 changes: 3 additions & 21 deletions app/views/foreman_setup/provisioners/_step4.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,17 @@

<h4><%= _("Operating system") %></h4>
<p><%= _("The following operating system will be configured for provisioning:") %></p>
<%= (icon(f.object.host.os, :size => "18x18") + " #{f.object.host.os}").html_safe %>
<%= content_tag(:div, :style => 'margin-left: 20px; margin-bottom: 30px;') { (icon(f.object.host.os, :size => "18x18") + " #{f.object.host.os}").html_safe } %>

<h6><%= _("Use an existing installation medium") %></h6>
<h5><%= _("Use an existing installation medium") %></h5>
<%= f.fields_for :hostgroup do |hgf| %>
<%= select_f hgf, :medium_id, Medium.all, :id, :name, {:include_blank => true}, {:label => _("Existing medium")} %>
<% end %>

<h6><%= _("Create new installation medium") %></h6>
<h5><%= _("Create new installation medium") %></h5>
<%= f.fields_for :create_medium, @medium do |mf| %>
<%= text_f mf, :name, :onchange => 'setup_media_create_change(this)' %>
<%= label_tag('', :class => 'radio inline') do %>
<% radio_button_tag(:medium_type, :path, true, :onchange => 'setup_media_change(this); setup_media_create_change(this)') + _("Normal installation media") %>
<% end %>
<%= text_f mf, :path, :label => _("Path or URL") %>
<%= label_tag('', :class => 'radio inline') do %>
<% radio_button_tag(:medium_type, :spacewalk, false, :onchange => 'setup_media_change(this); setup_media_create_change(this)') + _("Red Hat Satellite 5 or Spacewalk") %>
<% end %>
<%= field(f, :spacewalk_hostname, :label => _("Hostname")) { text_field_tag :spacewalk_hostname, nil, :disabled => true } %>
<% end %>

<h4><%= _("Activation key configuration") %></h4>
<p><%= _("Users of Spacewalk, Red Hat Network, or Red Hat Satellite 5 should enter an appropriate activation key below, otherwise leave blank.") %></p>
<%= f.fields_for :satellite_type, @satellite_type do |stf| %>
<%= selectable_f stf, :value, [['Red Hat Satellite or Spacewalk', 'site'], ['Red Hat Network', 'hosted']], {:include_blank => true}, {:label => _("Type")} %>
<% end %>
<%= f.fields_for :activation_key, @activation_key do |akf| %>
<%= text_f akf, :value, :label => _("Activation key") %>
<% end %>
<%= submit_or_cancel f, false, {:cancel_path => foreman_setup_provisioners_path, :disabled => !(f.object.host.present? && f.object.smart_proxy.present?)} %>
Expand Down
6 changes: 3 additions & 3 deletions app/views/foreman_setup/provisioners/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<% title _("Provisioning setup") %>
<% title_actions display_link_if_authorized(_("Set up provisioning"), hash_for_new_foreman_setup_provisioner_path), help_path %>
<% title_actions new_link(_("Set up provisioning")) %>

<table class="table table-bordered table-striped">
<table class="<%= table_css_classes %>">
<tr>
<th><%= sort :name, :as => _("Provisioning host") %></th>
<th><%= _("Smart proxy") %></th>
Expand All @@ -14,7 +14,7 @@
<td><%= link_to_if_authorized h(prov.host.to_s), hash_for_edit_foreman_setup_provisioner_path(prov)%></td>
<td><%= prov.smart_proxy.try(:name) %></td>
<td><%= "#{prov.subnet.name} (#{prov.subnet.to_label})" if prov.subnet.present? %></td>
<td><%= display_delete_if_authorized hash_for_foreman_setup_provisioner_path(prov), :confirm => _("Delete %s?") % prov.host.to_s %></td>
<td><%= action_buttons(display_delete_if_authorized(hash_for_foreman_setup_provisioner_path(prov), :confirm => _("Delete %s?") % prov.host.to_s)) %></td>
</tr>
<% end %>
</table>
Expand Down
9 changes: 1 addition & 8 deletions lib/foreman_setup/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Engine < ::Rails::Engine

initializer 'foreman_setup.register_plugin', :before => :finisher_hook do |app|
Foreman::Plugin.register :foreman_setup do
requires_foreman '>= 1.9.0'
requires_foreman '>= 1.12.0'

menu :top_menu, :provisioners, :url_hash => {:controller=> :'foreman_setup/provisioners', :action=>:index},
:caption=> N_('Provisioning setup'),
Expand All @@ -36,13 +36,6 @@ class Engine < ::Rails::Engine
locale_domain = 'foreman_setup'
Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
end

initializer 'foreman_setup.assets.precompile' do |app|
app.config.assets.precompile += ['foreman_setup/false.png']
end
initializer 'foreman_setup.configure_assets', group: :assets do
SETTINGS[:foreman_setup] = { assets: { precompile: ['foreman_setup/false.png'] } }
end
end

def table_name_prefix
Expand Down
2 changes: 0 additions & 2 deletions test/functional/foreman_setup/provisioners_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ class ForemanSetup::ProvisionersControllerTest < ActionController::TestCase
attrs = {
:hostgroup_attributes => {},
:create_medium => {:name => 'test', :path => 'http://mirror.example.com'},
:activation_key => {},
:satellite_type => {},
}
put :step4_update, {:id => prov.id, 'foreman_setup_provisioner' => attrs}, set_session_user
assert_redirected_to step5_foreman_setup_provisioner_path(prov)
Expand Down

0 comments on commit 23cd8ca

Please sign in to comment.