Sha256: 49c15de89be8fa5673f3069e043e986930a5a6464a0c951ac2fc6bc2075a47f6
Contents?: true
Size: 1.93 KB
Versions: 2
Compression:
Stored size: 1.93 KB
Contents
module Host::ManagedExtensions extend ActiveSupport::Concern included do # execute standard callbacks after_validation :queue_reboot after_save :delete_discovery_attribute_set belongs_to :discovery_rule # extra flag for post_queue callbacks which has no access to facts attr_accessor :legacy_api end def queue_reboot return unless errors.empty? && Setting[:discovery_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" # reboot task must be high priority and there is no compensation action apparently if facts['discovery_kexec'] && provisioning_template(:kind => 'kexec') post_queue.create(:name => _("Reloading kernel on %s") % self, :priority => 10000, :action => [self, :setKexec]) else post_queue.create(:name => _("Rebooting %s") % self, :priority => 10000, :action => [self, :setReboot]) end end def setReboot old.becomes(Host::Discovered).reboot legacy_api # It is too late to report error in the post_queue, we catch them and # continue. If flash is implemented for new hosts (http://projects.theforeman.org/issues/10559) # we can report the error to the user perhaps. true rescue ::Foreman::Exception true end def boot_url pxe_file operatingsystem.medium_vars_to_uri("#{medium.path}/#{operatingsystem.url_for_boot(pxe_file)}", architecture.name, operatingsystem).to_s end def setKexec template = provisioning_template(:kind => 'kexec') @host = self @kernel = boot_url(:kernel) @initrd = boot_url(:initrd) json = unattended_render(template) old.becomes(Host::Discovered).kexec json true rescue ::Foreman::Exception true end def delete_discovery_attribute_set return if new_record? DiscoveryAttributeSet.destroy_all(:host_id => self.id) if type_changed? end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
foreman_discovery-4.1.2 | app/models/host/managed_extensions.rb |
foreman_discovery-4.1.1 | app/models/host/managed_extensions.rb |