Class: Katello::SubscriptionStatus

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

Constant Summary collapse

DISABLED =
5
UNSUBSCRIBED_HYPERVISOR =
4
UNKNOWN =
3
INVALID =
2
PARTIAL =
1
VALID =
0

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.status_nameObject



10
11
12
# File 'app/models/katello/subscription_status.rb', line 10

def self.status_name
  N_("Subscription")
end

Instance Method Details

#relevant?(_options = {}) ⇒ Boolean

Returns:

  • (Boolean)


67
68
69
# File 'app/models/katello/subscription_status.rb', line 67

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

#to_global(_options = {}) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/models/katello/subscription_status.rb', line 31

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

#to_label(_options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/katello/subscription_status.rb', line 14

def to_label(_options = {})
  case status
  when VALID
    N_("Fully entitled")
  when PARTIAL
    N_("Partially entitled")
  when INVALID
    N_("Unentitled")
  when UNSUBSCRIBED_HYPERVISOR
    N_("Unsubscribed hypervisor")
  when DISABLED
    N_("Simple Content Access")
  else
    N_("Unknown subscription status")
  end
end

#to_status(options = {}) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/models/katello/subscription_status.rb', line 44

def to_status(options = {})
  return UNKNOWN unless host.subscription_facet.try(:uuid)
  return DISABLED if host.organization.simple_content_access?
  status_override = 'unsubscribed_hypervisor' if host.subscription_facet.unsubscribed_hypervisor?
  status_override ||= options.fetch(:status_override, nil)
  status = status_override || host.subscription_facet.candlepin_consumer.entitlement_status

  case status
  when Katello::Candlepin::Consumer::ENTITLEMENTS_DISABLED
    DISABLED
  when Katello::Candlepin::Consumer::ENTITLEMENTS_VALID
    VALID
  when Katello::Candlepin::Consumer::ENTITLEMENTS_PARTIAL
    PARTIAL
  when Katello::Candlepin::Consumer::ENTITLEMENTS_INVALID
    INVALID
  when 'unsubscribed_hypervisor'
    UNSUBSCRIBED_HYPERVISOR
  else
    UNKNOWN
  end
end