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

#errata_status_installableObject



12
13
14
# File 'app/models/katello/errata_status.rb', line 12

def errata_status_installable
  @installable ||= Setting[:errata_status_installable]
end

#profiles_reporter_package_nameObject



16
17
18
19
20
21
22
# File 'app/models/katello/errata_status.rb', line 16

def profiles_reporter_package_name
  if host.content_facet.host_tools_installed?
    Katello::Host::ContentFacet::HOST_TOOLS_PACKAGE_NAME
  else
    Katello::Host::ContentFacet::SUBSCRIPTION_MANAGER_PACKAGE_NAME
  end
end

#relevant?(_options = {}) ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
# File 'app/models/katello/errata_status.rb', line 72

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

#to_global(_options = {}) ⇒ Object



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

def to_global(_options = {})
  case 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



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

def to_label(_options = {})
  case status
  when NEEDED_SECURITY_ERRATA
    errata_status_installable ? N_("Security errata installable") : N_("Security errata applicable")
  when NEEDED_ERRATA
    errata_status_installable ? N_("Non-security errata installable") : N_("Non-security errata applicable")
  when UP_TO_DATE
    N_("All errata applied")
  when UNKNOWN
    N_("No installed packages and/or enabled repositories have been reported by %s." % profiles_reporter_package_name)
  else
    N_("Unknown errata status")
  end
end

#to_status(_options = {}) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'app/models/katello/errata_status.rb', line 54

def to_status(_options = {})
  errata = if errata_status_installable
             host.content_facet.try(:installable_errata)
           else
             host.content_facet.try(:applicable_errata)
           end

  if errata.security.any?
    NEEDED_SECURITY_ERRATA
  elsif errata.any?
    NEEDED_ERRATA
  elsif host.installed_packages.empty? || host.content_facet.bound_repositories.empty?
    UNKNOWN
  else
    UP_TO_DATE
  end
end