Sha256: fc42ca1e86be47c8d1d1377ae86e800731ec7d0af555c65ed7a3cbcb46a924ce
Contents?: true
Size: 1.22 KB
Versions: 1
Compression:
Stored size: 1.22 KB
Contents
require "log4r" require "timeout" module VagrantPlugins module HYPERKIT module Action # This action will wait for a machine to reach a specific state or quit by timeout class WaitForState # env[:result] will be false in case of timeout. # @param [Symbol] state Target machine state. # @param [Number] timeout Timeout in seconds. def initialize(app, env, state, timeout) @app = app @logger = Log4r::Logger.new("vagrant_hyperkit::action::wait_for_state") @state = state @timeout = timeout end def call(env) env[:result] = true if env[:machine].state.id == @state @logger.info(I18n.t("vagrant_hyperkit.already_status", :status => @state)) else @logger.info("Waiting for machine to reach state #{@state}") begin Timeout.timeout(@timeout) do until env[:machine].state.id == @state sleep 2 end end rescue Timeout::Error env[:result] = false # couldn't reach state in time end end @app.call(env) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vagrant-hyperkit-0.4.3 | lib/vagrant-hyperkit/action/wait_for_state.rb |