Sha256: 9be7f2fce7d35b86ca184fac1a9fb4cd65ebdd3e3bdd3f931f325e90a596b6a7

Contents?: true

Size: 1.43 KB

Versions: 13

Compression:

Stored size: 1.43 KB

Contents

module VagrantPlugins
  module ProviderVirtualBox
    module Action
      class Boot
        def initialize(app, env)
          @app = app
        end

        def call(env)
          @env = env

          boot_mode = @env[:machine].provider_config.gui ? "gui" : "headless"

          # Start up the VM and wait for it to boot.
          env[:ui].info I18n.t("vagrant.actions.vm.boot.booting")
          env[:machine].provider.driver.start(boot_mode)
          raise Vagrant::Errors::VMFailedToBoot if !wait_for_boot

          @app.call(env)
        end

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

          @env[:machine].config.ssh.max_tries.to_i.times do |i|
            if @env[:machine].communicate.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[:machine].provider.state.id
            raise Vagrant::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

13 entries across 13 versions & 5 rubygems

Version Path
vagrant-shell-0.2.9 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/plugins/providers/virtualbox/action/boot.rb
tnargav-1.2.3 plugins/providers/virtualbox/action/boot.rb
vagrant-shell-0.2.8 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/plugins/providers/virtualbox/action/boot.rb
vagrant-shell-0.2.6 vendor/bundle/gems/tnargav-1.2.2/plugins/providers/virtualbox/action/boot.rb
vagrant-shell-0.2.5 vendor/bundle/gems/tnargav-1.2.2/plugins/providers/virtualbox/action/boot.rb
tnargav-1.2.2 plugins/providers/virtualbox/action/boot.rb
vagrantup-1.1.3 plugins/providers/virtualbox/action/boot.rb
vagrantup-1.1.2 plugins/providers/virtualbox/action/boot.rb
vagrantup-1.1.1 plugins/providers/virtualbox/action/boot.rb
vagrantup-1.1.0 plugins/providers/virtualbox/action/boot.rb
vagrantup-1.1.4 plugins/providers/virtualbox/action/boot.rb
vagrant-actionio-0.0.9 vendor/bundle/bundler/gems/vagrant-c74251a1d9c0/plugins/providers/virtualbox/action/boot.rb
vagrant-lxc-0.0.1 vendor/vagrant/plugins/providers/virtualbox/action/boot.rb