Class: Katello::PurposeStatus

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

Constant Summary collapse

UNKNOWN =
0
MISMATCHED =
1
MATCHED =
2
NOT_SPECIFIED =
3

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.humanized_nameObject



23
24
25
# File 'app/models/katello/purpose_status.rb', line 23

def self.humanized_name
  'purpose'
end

.status_mapObject



8
9
10
11
12
13
14
15
16
17
# File 'app/models/katello/purpose_status.rb', line 8

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

  map.default = UNKNOWN
  map
end

.status_nameObject



19
20
21
# File 'app/models/katello/purpose_status.rb', line 19

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

.to_label(status) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/models/katello/purpose_status.rb', line 27

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

.to_status(status, purpose_method, options) ⇒ Object



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

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

Instance Method Details

#relevant?(_options = {}) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#to_global(_options = {}) ⇒ Object



55
56
57
58
59
60
61
# File 'app/models/katello/purpose_status.rb', line 55

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

#to_label(_options = {}) ⇒ Object



51
52
53
# File 'app/models/katello/purpose_status.rb', line 51

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

#to_status(options = {}) ⇒ Object



63
64
65
# File 'app/models/katello/purpose_status.rb', line 63

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