Sha256: 43839d6903a9bb4c9d295bee2fe4eca194508de53cf53497c1caa0ba7ed35a95

Contents?: true

Size: 1.05 KB

Versions: 16

Compression:

Stored size: 1.05 KB

Contents

module Nic::ManagedExtensions
  extend ActiveSupport::Concern

  included do
    after_validation :discovery_queue_rebuild_dns
  end

  def discovery_queue_rebuild_dns
    return unless (dns? || dns6? || reverse_dns? || reverse_dns6?) && errors.empty? && Setting[:discovery_always_rebuild_dns]
    return if self.host.new_record? || old.nil? # Discovered Hosts already exist, and new_records will break `find`
    return unless self.host.type_changed? and ::Host::Base.find(self.host.id).type == "Host::Discovered"
    return if self.pending_dns_record_changes?
    logger.debug "Queuing DNS rebuild for #{self}"
    queue.create(:name => _("Rebuild DNS for %s") % self, :priority => 10, :action => [self, :set_discovery_rebuild_dns])
  end

  def set_discovery_rebuild_dns
    logger.debug "Executing DNS rebuild for #{self}"
    rebuild_dns
  end

  def del_discovery_rebuild_dns
    # Just a place holder, so if rollback is needed, we won't get an exception about not knowing how to rollback.
    # This is a no-op, since we cannot really rollback rebuild_dns
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
foreman_discovery-13.0.1 app/models/nic/managed_extensions.rb
foreman_discovery-12.0.2 app/models/nic/managed_extensions.rb
foreman_discovery-12.0.1 app/models/nic/managed_extensions.rb
foreman_discovery-12.0.0 app/models/nic/managed_extensions.rb
foreman_discovery-11.0.0 app/models/nic/managed_extensions.rb
foreman_discovery-9.1.5 app/models/nic/managed_extensions.rb
foreman_discovery-9.1.4 app/models/nic/managed_extensions.rb
foreman_discovery-10.0.0 app/models/nic/managed_extensions.rb
foreman_discovery-9.1.3 app/models/nic/managed_extensions.rb
foreman_discovery-9.1.2 app/models/nic/managed_extensions.rb
foreman_discovery-9.1.1 app/models/nic/managed_extensions.rb
foreman_discovery-9.1.0 app/models/nic/managed_extensions.rb
foreman_discovery-9.0.0 app/models/nic/managed_extensions.rb
foreman_discovery-8.0.1 app/models/nic/managed_extensions.rb
foreman_discovery-8.0.0 app/models/nic/managed_extensions.rb
foreman_discovery-7.0.1 app/models/nic/managed_extensions.rb