Class: Katello::TraceStatus

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

Constant Summary collapse

REQUIRE_REBOOT =
2
REQUIRE_PROCESS_RESTART =
1
UP_TO_DATE =
0
UNKNOWN =
-1

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.status_nameObject



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

def self.status_name
  N_("Traces")
end

Instance Method Details

#relevant?(_options = {}) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
54
55
# File 'app/models/katello/trace_status.rb', line 51

def relevant?(_options = {})
  # traces cannot be reported from hosts lower than el7
  return false if host.operatingsystem.try(:major).to_i.between?(1, 6) || !host.content_facet&.tracer_installed?
  host.content_facet.try(:uuid).present?
end

#to_global(_options = {}) ⇒ Object



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

def to_global(_options = {})
  case to_status
  when REQUIRE_REBOOT
    ::HostStatus::Global::ERROR
  when REQUIRE_PROCESS_RESTART
    ::HostStatus::Global::WARN
  when UP_TO_DATE
    ::HostStatus::Global::OK
  else
    ::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/trace_status.rb', line 12

def to_label(_options = {})
  case to_status
  when REQUIRE_REBOOT
    N_("Reboot required")
  when REQUIRE_PROCESS_RESTART
    N_("One or more processes require restarting")
  when UP_TO_DATE
    N_("No processes require restarting")
  else
    N_("Unknown traces status")
  end
end

#to_status(_options = {}) ⇒ Object



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

def to_status(_options = {})
  traces = host.host_traces.reload.pluck(:app_type)
  traces.delete(Katello::HostTracer::TRACE_APP_TYPE_SESSION)

  if traces.include?(Katello::HostTracer::TRACE_APP_TYPE_STATIC)
    REQUIRE_REBOOT
  elsif !traces.empty?
    REQUIRE_PROCESS_RESTART
  else
    UP_TO_DATE
  end
end