Sha256: 92eef504f3347fc12b63e624afcd4545279aeab88feefa37cdfaa6b167af6da2

Contents?: true

Size: 1.28 KB

Versions: 18

Compression:

Stored size: 1.28 KB

Contents

module Katello
  class HostTracer < Katello::Model
    include Katello::Authorization::HostTracer

    TRACE_APP_TYPE_STATIC = 'static'.freeze
    TRACE_APP_TYPE_SESSION = 'session'.freeze
    TRACE_APP_TYPE_DAEMON = 'daemon'.freeze

    belongs_to :host, :inverse_of => :host_traces, :class_name => '::Host::Managed'

    scope :reboot_required, -> { where(app_type: TRACE_APP_TYPE_STATIC) }
    scope :selectable, -> { where.not(app_type: TRACE_APP_TYPE_SESSION) }

    validates :application, :length => {:maximum => 255}, :presence => true
    validates :app_type, :length => {:maximum => 255}, :presence => true

    scoped_search :on => :id, :only_explicit => true
    scoped_search :on => :application, :complete_value => true
    scoped_search :on => :app_type, :complete_value => true
    scoped_search :on => :helper, :complete_value => true

    def reboot_required?
      self.app_type == TRACE_APP_TYPE_STATIC
    end

    def restart_command
      case self.app_type
      when TRACE_APP_TYPE_STATIC
        'reboot'
      when TRACE_APP_TYPE_SESSION
        nil
      else
        self.helper
      end
    end

    def self.helpers_for(traces)
      if traces.any?(&:reboot_required?)
        ['reboot']
      else
        traces.map(&:restart_command).compact.uniq
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
katello-4.14.2 app/models/katello/host_tracer.rb
katello-4.15.0 app/models/katello/host_tracer.rb
katello-4.15.0.rc2 app/models/katello/host_tracer.rb
katello-4.15.0.rc1 app/models/katello/host_tracer.rb
katello-4.14.1 app/models/katello/host_tracer.rb
katello-4.14.0 app/models/katello/host_tracer.rb
katello-4.14.0.rc3 app/models/katello/host_tracer.rb
katello-4.14.0.rc2 app/models/katello/host_tracer.rb
katello-4.14.0.rc1.1 app/models/katello/host_tracer.rb
katello-4.14.0.rc1 app/models/katello/host_tracer.rb
katello-4.13.1 app/models/katello/host_tracer.rb
katello-4.13.0 app/models/katello/host_tracer.rb
katello-4.12.1 app/models/katello/host_tracer.rb
katello-4.13.0.rc1 app/models/katello/host_tracer.rb
katello-4.12.0 app/models/katello/host_tracer.rb
katello-4.12.0.rc3 app/models/katello/host_tracer.rb
katello-4.12.0.rc2 app/models/katello/host_tracer.rb
katello-4.12.0.rc1 app/models/katello/host_tracer.rb