Class: Actions::Staypuft::Host::WaitUntilProvisioned

Inherits:
Base
  • Object
show all
Defined in:
app/lib/actions/staypuft/host/wait_until_provisioned.rb

Constant Summary collapse

TIMEOUT =
7200

Instance Method Summary collapse

Instance Method Details

#plan(host) ⇒ Object



27
28
29
# File 'app/lib/actions/staypuft/host/wait_until_provisioned.rb', line 27

def plan(host)
  plan_self host_id: host.id
end

#run(event = nil) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/lib/actions/staypuft/host/wait_until_provisioned.rb', line 31

def run(event = nil)
  case event
  when nil
    suspend do |suspended_action|
      # schedule timeout
      world.clock.ping suspended_action, input[:timeout], "timeout"

      # wake up when provisioning is finished
      Rails.cache.write(
          ::Staypuft::Concerns::HostOrchestrationBuildHook.cache_id(input[:host_id]),
          { execution_plan_id: suspended_action.execution_plan_id,
            step_id:           suspended_action.step_id })
    end
  when "timeout"
    # clear timeout_start so that the action can be resumed/skipped
    output[:timeout_start] = nil
    fail(::Staypuft::Exception,
         "You've reached the timeout set for this action. If the " +
         "action is still ongoing, you can click on the " +
         "\"Resume Deployment\" button to continue.")
  when Hash
    output[:installed_at] = event.fetch(:installed_at).to_s
  when Dynflow::Action::Skip
    output[:installed_at] = Time.now.utc.to_s
  else
    raise TypeError
  end
end

#run_progressObject



64
65
66
# File 'app/lib/actions/staypuft/host/wait_until_provisioned.rb', line 64

def run_progress
  0.1
end

#run_progress_weightObject



60
61
62
# File 'app/lib/actions/staypuft/host/wait_until_provisioned.rb', line 60

def run_progress_weight
  4
end