Sha256: 0313a22bfdd1447691dcc8cb4d60b60dfdf7c4dada1e2acb7cb131688a9660cc
Contents?: true
Size: 1.03 KB
Versions: 5
Compression:
Stored size: 1.03 KB
Contents
module Host::ManagedExtensions extend ActiveSupport::Concern included do # execute standard callbacks after_validation :queue_reboot end 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 #{self}", :priority => 10000, :action => [self, :setReboot]) end 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: #{proxy_error e}" end 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 end
Version data entries
5 entries across 5 versions & 1 rubygems