Sha256: 449974088d209e6eb005383c5401cb3fce9c86a49f10c940a52100454408b146

Contents?: true

Size: 1.13 KB

Versions: 6

Compression:

Stored size: 1.13 KB

Contents

# This acts like a backport of Vagrant's built in action from 1.3+ for older versions
# and will probably be deprecated on 0.8+
#   https://github.com/mitchellh/vagrant/blob/master/lib/vagrant/action/builtin/wait_for_communicator.rb
module Vagrant
  module LXC
    module Action
      class WaitForCommunicator
        def initialize(app, env)
          @app    = app
        end

        def call(env)
          @env = env

          raise Vagrant::Errors::VMFailedToBoot if !wait_for_communicator

          @app.call env
        end

        def wait_for_communicator
          max_tries = @env[:machine].config.ssh.max_tries.to_i
          max_tries.times do |i|
            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]

            sleep 1 if !@env["vagrant.test"]
          end

          @env[:ui].error I18n.t("vagrant.actions.vm.boot.failed")
          false
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vagrant-lxc-0.8.0 lib/vagrant-lxc/action/wait_for_communicator.rb
vagrant-lxc-0.7.0 lib/vagrant-lxc/action/wait_for_communicator.rb
vagrant-lxc-0.6.4 lib/vagrant-lxc/action/wait_for_communicator.rb
vagrant-lxc-0.6.3 lib/vagrant-lxc/action/wait_for_communicator.rb
vagrant-lxc-0.6.2 lib/vagrant-lxc/action/wait_for_communicator.rb
vagrant-lxc-0.6.1 lib/vagrant-lxc/action/wait_for_communicator.rb