Sha256: 26f255735dd7f6c2c143a279c49dfe8a30f9dc5e90acd11831b08e6a43a44893

Contents?: true

Size: 1.45 KB

Versions: 46

Compression:

Stored size: 1.45 KB

Contents

module Katello
  class PurposeStatus < HostStatus::Status
    MATCHED = 0
    MISMATCHED = 1
    UNKNOWN = 2
    NOT_SPECIFIED = 3

    def self.status_map
      map = {
        mismatched: MISMATCHED,
        matched: MATCHED,
        not_specified: NOT_SPECIFIED
      }

      map.default = UNKNOWN
      map
    end

    def self.status_name
      N_('System Purpose')
    end

    def self.humanized_name
      'purpose'
    end

    def self.to_label(status)
      case status
      when MATCHED
        N_('Matched')
      when MISMATCHED
        N_('Mismatched')
      when NOT_SPECIFIED
        N_('Not Specified')
      else
        N_('Unknown')
      end
    end

    def self.to_status(status, purpose_method, options)
      return UNKNOWN unless status.relevant?

      if options.key?(:status_override)
        return self.status_map[options[:status_override]]
      end

      consumer = status.host.subscription_facet.candlepin_consumer
      self.status_map[consumer.system_purpose.send(purpose_method)]
    end

    def to_label(_options = {})
      self.class.to_label(status)
    end

    def to_global(_options = {})
      if [MATCHED, UNKNOWN, NOT_SPECIFIED].include?(status)
        ::HostStatus::Global::OK
      else
        ::HostStatus::Global::WARN
      end
    end

    def to_status(options = {})
      self.class.to_status(self, :overall_status, options)
    end

    def relevant?(_options = {})
      host.subscription_facet.try(:uuid)
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
katello-3.16.2 app/models/katello/purpose_status.rb
katello-3.16.1.2 app/models/katello/purpose_status.rb
katello-3.16.1.1 app/models/katello/purpose_status.rb
katello-3.16.1 app/models/katello/purpose_status.rb
katello-3.17.0.rc1 app/models/katello/purpose_status.rb
katello-3.16.0 app/models/katello/purpose_status.rb
katello-3.16.0.rc5.1 app/models/katello/purpose_status.rb
katello-3.16.0.rc5 app/models/katello/purpose_status.rb
katello-3.16.0.rc4.1 app/models/katello/purpose_status.rb
katello-3.15.3.1 app/models/katello/purpose_status.rb
katello-3.15.3 app/models/katello/purpose_status.rb
katello-3.16.0.rc4 app/models/katello/purpose_status.rb
katello-3.16.0.rc3.1 app/models/katello/purpose_status.rb
katello-3.15.2 app/models/katello/purpose_status.rb
katello-3.16.0.rc3 app/models/katello/purpose_status.rb
katello-3.16.0.rc2.1 app/models/katello/purpose_status.rb
katello-3.16.0.rc2 app/models/katello/purpose_status.rb
katello-3.15.1.1 app/models/katello/purpose_status.rb
katello-3.16.0.rc1.1 app/models/katello/purpose_status.rb
katello-3.15.1 app/models/katello/purpose_status.rb