Class: Actions::ForemanPatch::Window::Patch

Inherits:
EntryAction
  • Object
show all
Defined in:
app/lib/actions/foreman_patch/window/patch.rb

Instance Method Summary collapse

Instance Method Details

#delay(delay_options, window) ⇒ Object



11
12
13
14
15
16
17
18
# File 'app/lib/actions/foreman_patch/window/patch.rb', line 11

def delay(delay_options, window)
  window.task_id = task.id
  window.save!

  action_subject(window)

  super delay_options, window
end

#humanized_nameObject



46
47
48
49
50
51
52
# File 'app/lib/actions/foreman_patch/window/patch.rb', line 46

def humanized_name
  if input and input[:window][:name]
    _('Run Patch Window: %{window}' % {window: input[:window][:name]})
  else
    _('Run Patch Window')
  end
end

#plan(window) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/lib/actions/foreman_patch/window/patch.rb', line 20

def plan(window)
  window.task_id = task.id
  window.save!

  action_subject(window)

  sequence do
    window.rounds.group_by(&:priority).each do |_, groups|
      concurrence do
        groups.each do |group|
          plan_action(Actions::ForemanPatch::Round::Patch, group)
        end
      end
    end
  end
  plan_self
end

#rescue_strategy_for_selfObject



42
43
44
# File 'app/lib/actions/foreman_patch/window/patch.rb', line 42

def rescue_strategy_for_self
  ::Dynflow::Action::Rescue::Fail
end

#resource_locksObject



7
8
9
# File 'app/lib/actions/foreman_patch/window/patch.rb', line 7

def resource_locks
  :link
end

#update_window_status(execution_plan) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/lib/actions/foreman_patch/window/patch.rb', line 54

def update_window_status(execution_plan)
  return unless root_action?

  case execution_plan.state
  when :scheduled
    window.status = 'scheduled'
  when :pending, :planning, :planned, :running
    window.status = 'running'
  when :stopped
    window.status = 'completed'
  else
    window.status = execution_plan.state
  end
  window.save!
end

#windowObject



38
39
40
# File 'app/lib/actions/foreman_patch/window/patch.rb', line 38

def window
  @window ||= ::ForemanPatch::Window.find(input[:window][:id])
end