Module: Host::ManagedExtensions

Extended by:
ActiveSupport::Concern
Defined in:
app/models/host/managed_extensions.rb

Instance Method Summary collapse

Instance Method Details

#delRebootObject



27
28
29
30
# File 'app/models/host/managed_extensions.rb', line 27

def delReboot
  # nothing to do here, in reality we should never hit this method since this should be the
  # last action in the queue.
end

#queue_rebootObject



9
10
11
12
13
14
# File 'app/models/host/managed_extensions.rb', line 9

def queue_reboot
  return if new_record? # Discovered Hosts already exist, and new_records will break `find`
  return unless type_changed? and ::Host::Base.find(self.id).type == "Host::Discovered"
  post_queue.create(:name => _("Rebooting %s") % self, :priority => 10000,
                    :action => [self, :setReboot])
end

#setRebootObject



16
17
18
19
20
21
22
23
24
25
# File 'app/models/host/managed_extensions.rb', line 16

def setReboot
  logger.info "ForemanDiscovery: Rebooting #{name} as its being discovered and assigned"
  if ::ProxyAPI::BMC.new(:url => "http://#{old.try(:ip) || ip}:8443").power :action => "cycle"
    logger.info "ForemanDiscovery: reboot result: successful"
  else
    logger.info "ForemanDiscovery: reboot result: failed"
  end
rescue => e
  failure _("Failed to reboot: %s") % e.message
end