Class: HostStatus::ExecutionStatus

Inherits:
Status
  • Object
show all
Defined in:
app/models/host_status/execution_status.rb

Defined Under Namespace

Classes: ExecutionTaskStatusMapper

Constant Summary collapse

OK =

execution finished successfully

0
ERROR =

execution finished with error

1
QUEUED =

execution hasn’t started yet, either scheduled to future or executor didn’t create task yet

2
RUNNING =

execution is in progress, dynflow task was created

3
STATUS_NAMES =

mapping to string representation

{ OK => 'succeeded', ERROR => 'failed', QUEUED => 'queued', RUNNING => 'running' }

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.status_nameObject



29
30
31
# File 'app/models/host_status/execution_status.rb', line 29

def self.status_name
  N_('Execution')
end

Instance Method Details

#relevant?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'app/models/host_status/execution_status.rb', line 13

def relevant?
  execution_tasks.present?
end

#to_global(options = {}) ⇒ Object



21
22
23
24
25
26
27
# File 'app/models/host_status/execution_status.rb', line 21

def to_global(options = {})
  if to_status(options) == ERROR
    return HostStatus::Global::ERROR
  else
    return HostStatus::Global::OK
  end
end

#to_label(options = {}) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'app/models/host_status/execution_status.rb', line 33

def to_label(options = {})
  case to_status(options)
    when OK
      execution_tasks.present? ? N_('Last execution succeeded') : N_('No execution finished yet')
    when ERROR
      N_('Last execution failed')
    else
      N_('Unknown execution status')
  end
end

#to_status(options = {}) ⇒ Object



17
18
19
# File 'app/models/host_status/execution_status.rb', line 17

def to_status(options = {})
  ExecutionTaskStatusMapper.new(last_stopped_task).status
end