Sha256: 235f3801941dece71ef8615031cdfda16dc49f9f1014267949cd8d8a0f7ef408

Contents?: true

Size: 1.36 KB

Versions: 19

Compression:

Stored size: 1.36 KB

Contents

module Vagrant
  module Action
    module VM
      class Boot
        def initialize(app, env)
          @app = app
          @env = env
        end

        def call(env)
          @env = env

          # Start up the VM and wait for it to boot.
          boot
          raise Errors::VMFailedToBoot if !wait_for_boot

          @app.call(env)
        end

        def boot
          @env[:ui].info I18n.t("vagrant.actions.vm.boot.booting")
          @env[:vm].driver.start(@env[:vm].config.vm.boot_mode)
        end

        def wait_for_boot
          @env[:ui].info I18n.t("vagrant.actions.vm.boot.waiting")

          @env[:vm].config.ssh.max_tries.to_i.times do |i|
            if @env[:vm].channel.ready?
              @env[:ui].info I18n.t("vagrant.actions.vm.boot.ready")
              return true
            end

            # Return true so that the vm_failed_to_boot error doesn't
            # get shown
            return true if @env[:interrupted]

            # If the VM is not starting or running, something went wrong
            # and we need to show a useful error.
            state = @env[:vm].state
            raise Errors::VMFailedToRun if state != :starting && state != :running

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

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

Version data entries

19 entries across 19 versions & 6 rubygems

Version Path
bmhatfield-vagrant-1.0.10 lib/vagrant/action/vm/boot.rb
bmhatfield-vagrant-1.0.9 lib/vagrant/action/vm/boot.rb
bmhatfield-vagrant-1.0.8 lib/vagrant/action/vm/boot.rb
bmhatfield-vagrant-1.0.7 lib/vagrant/action/vm/boot.rb
vagrantup-1.0.7 lib/vagrant/action/vm/boot.rb
vagrantup-1.0.6 lib/vagrant/action/vm/boot.rb
vagrantup-1.0.5 lib/vagrant/action/vm/boot.rb
vagrantup-1.0.4 lib/vagrant/action/vm/boot.rb
vagrantup-1.0.3 lib/vagrant/action/vm/boot.rb
vagrantup-1.0.2 lib/vagrant/action/vm/boot.rb
vagrant-fixed-ssh-1.0.7 lib/vagrant/action/vm/boot.rb
vagrant-1.0.7 lib/vagrant/action/vm/boot.rb
vagrant-1.0.6 lib/vagrant/action/vm/boot.rb
boxcar-0.10005.1 lib/vagrant/action/vm/boot.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/vagrant-1.0.5/lib/vagrant/action/vm/boot.rb
vagrant-1.0.5 lib/vagrant/action/vm/boot.rb
vagrant-1.0.4 lib/vagrant/action/vm/boot.rb
vagrant-1.0.3 lib/vagrant/action/vm/boot.rb
vagrant-1.0.2 lib/vagrant/action/vm/boot.rb