Class: Katello::SubscriptionStatus

Inherits:
HostStatus::Status
  • Object
show all
Defined in:
app/models/katello/subscription_status.rb

Constant Summary collapse

UNKNOWN =
3
INVALID =
2
PARTIAL =
1
VALID =
0

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.status_nameObject



8
9
10
# File 'app/models/katello/subscription_status.rb', line 8

def self.status_name
  N_("Subscription")
end

Instance Method Details

#relevant?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'app/models/katello/subscription_status.rb', line 52

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

#to_global(_options = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/models/katello/subscription_status.rb', line 25

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

#to_label(_options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/models/katello/subscription_status.rb', line 12

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

#to_status(_options = {}) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/models/katello/subscription_status.rb', line 38

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