Module: VagrantPlugins::Linode::Helpers::Waiter

Includes:
Vagrant::Util::Retryable
Included in:
Actions::Create, Actions::PowerOff, Actions::PowerOn, Actions::Rebuild, Actions::Reload
Defined in:
lib/vagrant-linode/helpers/waiter.rb

Instance Method Summary collapse

Instance Method Details

#wait_for_event(env, id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/vagrant-linode/helpers/waiter.rb', line 6

def wait_for_event(env, id)
  retryable(tries: 120, sleep: 10) do
    # stop waiting if interrupted
    next if env[:interrupted]
    # check action status
    result = env[:linode_api].linode.job.list(jobid: id, linodeid: env[:machine].id)
    result = result[0] if result.is_a?(Array)

    yield result if block_given?
    fail 'not ready' if result['host_finish_dt'] > ''
  end
end