Sha256: df0a6c80e8fd1206c70a126ed9a52b120b4c0ea09b05636df92d28252e56d723

Contents?: true

Size: 1.71 KB

Versions: 13

Compression:

Stored size: 1.71 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 = {})
      installable = Setting[:errata_status_installable]
      case to_status
      when NEEDED_SECURITY_ERRATA
        installable ? N_("Security errata installable") : N_("Security errata applicable")
      when NEEDED_ERRATA
        installable ? N_("Non-security errata installable") : 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?

      if Setting[:errata_status_installable]
        errata = host.content_facet.try(:installable_errata)
      else
        errata = host.content_facet.try(:applicable_errata)
      end

      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?(_options = {})
      host.content_facet.try(:uuid)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
katello-3.4.0.2 app/models/katello/errata_status.rb
katello-3.4.0.1 app/models/katello/errata_status.rb
katello-3.3.2 app/models/katello/errata_status.rb
katello-3.4.0 app/models/katello/errata_status.rb
katello-3.4.0.rc2 app/models/katello/errata_status.rb
katello-3.4.0.rc1 app/models/katello/errata_status.rb
katello-3.3.1.1 app/models/katello/errata_status.rb
katello-3.3.1 app/models/katello/errata_status.rb
katello-3.3.0.1 app/models/katello/errata_status.rb
katello-3.3.0 app/models/katello/errata_status.rb
katello-3.3.0.rc2 app/models/katello/errata_status.rb
katello-3.3.0.rc1.1 app/models/katello/errata_status.rb
katello-3.3.0.rc1 app/models/katello/errata_status.rb