Sha256: 68e90a20c71c60d89432506b292efff3b754ccee2b7a6db6d71d062ced63a98e

Contents?: true

Size: 1.24 KB

Versions: 13

Compression:

Stored size: 1.24 KB

Contents

module Katello
  class SubscriptionStatus < HostStatus::Status
    UNKNOWN = 3
    INVALID = 2
    PARTIAL = 1
    VALID = 0

    def self.status_name
      N_("Subscription")
    end

    def to_label(_options = {})
      case status
      when VALID
        N_("Fully entitled")
      when PARTIAL
        N_("Partially entitled")
      when INVALID
        N_("Unentitled")
      else
        N_("Unknown subscription status")
      end
    end

    def to_global(_options = {})
      case status
      when INVALID
        ::HostStatus::Global::ERROR
      when PARTIAL
        ::HostStatus::Global::WARN
      when VALID
        ::HostStatus::Global::OK
      when UNKNOWN
        ::HostStatus::Global::WARN
      end
    end

    def to_status(_options = {})
      return UNKNOWN unless host.subscription_facet.try(:uuid)
      case Katello::Candlepin::Consumer.new(host.subscription_facet.uuid).entitlement_status
      when Katello::Candlepin::Consumer::ENTITLEMENTS_VALID
        VALID
      when Katello::Candlepin::Consumer::ENTITLEMENTS_PARTIAL
        PARTIAL
      when Katello::Candlepin::Consumer::ENTITLEMENTS_INVALID
        INVALID
      else
        UNKNOWN
      end
    end

    def relevant?
      host.subscription_facet.try(:uuid)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

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