Sha256: 5cb3c4ae1f3e66fb7f9b6e68265edd2cf4bb20198919e81408193f8decb6826b

Contents?: true

Size: 1.4 KB

Versions: 10

Compression:

Stored size: 1.4 KB

Contents

module Katello
  class ErrataStatus < HostStatus::Status
    NEEDED_SECURITY_ERRATA = 3
    NEEDED_ERRATA = 2
    UNKNOWN = 1
    UP_TO_DATE = 0

    def self.status_name
      N_("Errata")
    end

    def to_label(_options = {})
      case to_status
      when NEEDED_SECURITY_ERRATA
        N_("Security errata applicable")
      when NEEDED_ERRATA
        N_("Non-security errata applicable")
      when UP_TO_DATE
        N_("All errata applied")
      when UNKNOWN
        N_("Could not calculate errata status, ensure host is registered and katello-agent is installed")
      else
        N_("Unknown errata status")
      end
    end

    def to_global(_options = {})
      case to_status
      when NEEDED_SECURITY_ERRATA
        ::HostStatus::Global::ERROR
      when NEEDED_ERRATA
        ::HostStatus::Global::WARN
      when UP_TO_DATE
        ::HostStatus::Global::OK
      when UNKNOWN
        ::HostStatus::Global::WARN
      else
        ::HostStatus::Global::WARN
      end
    end

    def to_status(_options = {})
      return UNKNOWN if host.content_facet.nil?

      errata = host.content_facet.try(:applicable_errata)
      if errata.security.any?
        NEEDED_SECURITY_ERRATA
      elsif errata.any?
        NEEDED_ERRATA
      elsif host.content_facet.bound_repositories.empty?
        UNKNOWN
      else
        UP_TO_DATE
      end
    end

    def relevant?
      host.content_facet
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
katello-3.0.2 app/models/katello/errata_status.rb
katello-3.1.0.rc1 app/models/katello/errata_status.rb
katello-3.0.1 app/models/katello/errata_status.rb
katello-3.0.0 app/models/katello/errata_status.rb
katello-3.0.0.rc7 app/models/katello/errata_status.rb
katello-3.0.0.rc5 app/models/katello/errata_status.rb
katello-3.0.0.rc4 app/models/katello/errata_status.rb
katello-3.0.0.rc3 app/models/katello/errata_status.rb
katello-3.0.0.rc2 app/models/katello/errata_status.rb
katello-3.0.0.rc1 app/models/katello/errata_status.rb