Class: ForemanRescue::HostsController

Inherits:
HostsController
  • Object
show all
Defined in:
app/controllers/foreman_rescue/hosts_controller.rb

Instance Method Summary collapse

Instance Method Details

#cancel_rescueObject



36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/foreman_rescue/hosts_controller.rb', line 36

def cancel_rescue
  if @host.cancel_rescue
    process_success :success_msg => _('Canceled booting into rescue system for %s.') % @host.name, :success_redirect => :back
  else
    process_error :redirect => :back,
      :error_msg => _('Failed to cancel booting into rescue system for %{hostname} with the following errors: %{errors}') % {
        :hostname => @host.name,
        :errors => @host.errors.full_messages.to_sentence,
      }
  end
end

#rescueObject



8
9
# File 'app/controllers/foreman_rescue/hosts_controller.rb', line 8

def rescue
end

#set_rescueObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/foreman_rescue/hosts_controller.rb', line 11

def set_rescue
  forward_url_options
  if @host.set_rescue
    if params[:host] && params[:host][:rescue_mode] == '1'
      begin
        message = if @host.power.reset
                    _('Enabled %s for reboot into rescue system.')
                  else
                    _('Enabled %s for boot into rescue system on next boot, but failed to power cycle the host.')
                  end
        process_success :success_msg => message % @host, :success_redirect => :back
      rescue StandardError => e
        message = _('Failed to reboot %s.') % @host
        warning(message)
        Foreman::Logging.exception(message, e)
        process_success :success_msg => _('Enabled %s for rescue system on next boot.') % @host, :success_redirect => :back
      end
    else
      process_success :success_msg => _('Enabled %s for rescue system on next boot.') % @host, :success_redirect => :back
    end
  else
    process_error :redirect => :back, :error_msg => _('Failed to enable %{host} for rescue system: %{errors}') % { :host => @host, :errors => @host.errors.full_messages.to_sentence }
  end
end