2013-09-12 01:33:22 +00:00
|
|
|
# This acts like a backport of Vagrant's built in action from 1.3+ for older versions
|
2013-09-27 15:27:25 +00:00
|
|
|
# and will probably be deprecated on 0.8+
|
2013-09-12 01:33:22 +00:00
|
|
|
# https://github.com/mitchellh/vagrant/blob/master/lib/vagrant/action/builtin/wait_for_communicator.rb
|
|
|
|
module Vagrant
|
|
|
|
module LXC
|
|
|
|
module Action
|
|
|
|
class WaitForCommunicator
|
2013-09-27 15:27:25 +00:00
|
|
|
def initialize(app, env)
|
2013-09-12 01:33:22 +00:00
|
|
|
@app = app
|
|
|
|
end
|
|
|
|
|
|
|
|
def call(env)
|
|
|
|
@env = env
|
2013-09-27 15:27:25 +00:00
|
|
|
|
|
|
|
raise Vagrant::Errors::VMFailedToBoot if !wait_for_communicator
|
|
|
|
|
2013-09-12 01:33:22 +00:00
|
|
|
@app.call env
|
|
|
|
end
|
|
|
|
|
2013-09-27 15:27:25 +00:00
|
|
|
def wait_for_communicator
|
|
|
|
max_tries = @env[:machine].config.ssh.max_tries.to_i
|
|
|
|
max_tries.times do |i|
|
2013-09-12 01:33:22 +00:00
|
|
|
if @env[:machine].communicate.ready?
|
|
|
|
@env[:ui].info I18n.t("vagrant_lxc.messages.container_ready")
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
# Return true so that the vm_failed_to_boot error doesn't
|
|
|
|
# get shown
|
|
|
|
return true if @env[:interrupted]
|
|
|
|
|
2013-09-27 15:27:25 +00:00
|
|
|
sleep 1 if !@env["vagrant.test"]
|
2013-09-12 01:33:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
@env[:ui].error I18n.t("vagrant.actions.vm.boot.failed")
|
|
|
|
false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|