Class: Katello::ErrataStatus

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

Constant Summary collapse

NEEDED_SECURITY_ERRATA =
3
NEEDED_ERRATA =
2
UNKNOWN =
1
UP_TO_DATE =
0

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.status_nameObject



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

def self.status_name
  N_("Errata")
end

Instance Method Details

#relevant?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'app/models/katello/errata_status.rb', line 57

def relevant?
  host.content_facet
end

#to_global(_options = {}) ⇒ Object



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

def to_global(_options = {})
  case to_status
  when NEEDED_SECURITY_ERRATA
    ::HostStatus::Global::ERROR
  when NEEDED_ERRATA
    ::HostStatus::Global::WARN
  when UP_TO_DATE
    ::HostStatus::Global::OK
  when UNKNOWN
    ::HostStatus::Global::WARN
  else
    ::HostStatus::Global::WARN
  end
end

#to_label(_options = {}) ⇒ Object



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

def to_label(_options = {})
  case to_status
  when NEEDED_SECURITY_ERRATA
    N_("Security errata applicable")
  when NEEDED_ERRATA
    N_("Non-security errata applicable")
  when UP_TO_DATE
    N_("All errata applied")
  when UNKNOWN
    N_("Could not calculate errata status, ensure host is registered and katello-agent is installed")
  else
    N_("Unknown errata status")
  end
end

#to_status(_options = {}) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/models/katello/errata_status.rb', line 42

def to_status(_options = {})
  return UNKNOWN if host.content_facet.nil?

  errata = host.content_facet.try(:applicable_errata)
  if errata.security.any?
    NEEDED_SECURITY_ERRATA
  elsif errata.any?
    NEEDED_ERRATA
  elsif host.content_facet.bound_repositories.empty?
    UNKNOWN
  else
    UP_TO_DATE
  end
end