Sha256: c5006726631c647b291b6c9fc015f148eb4735ecb11249d8712ae95c6f787dbe

Contents?: true

Size: 1.24 KB

Versions: 10

Compression:

Stored size: 1.24 KB

Contents

module Vagrant
  module Actions
    module VM
      class Boot < Base
        def prepare
          @runner.env.config.vm.share_folder("v-root", @runner.env.config.vm.project_directory, @runner.env.root_path)
        end

        def execute!
          @runner.invoke_around_callback(:boot) do
            # Startup the VM
            boot

            # Wait for it to complete booting, or error if we could
            # never detect it booted up successfully
            if !wait_for_boot
              error_and_exit(:vm_failed_to_boot)
            end
          end
        end

        def boot
          logger.info "Booting VM..."
          @runner.vm.start(@runner.env.config.vm.boot_mode)
        end

        def wait_for_boot(sleeptime=5)
          logger.info "Waiting for VM to boot..."

          @runner.env.config.ssh.max_tries.to_i.times do |i|
            logger.info "Trying to connect (attempt ##{i+1} of #{Vagrant.config[:ssh][:max_tries]})..."

            if @runner.env.ssh.up?
              logger.info "VM booted and ready for use!"
              return true
            end

            sleep sleeptime
          end

          logger.info "Failed to connect to VM! Failed to boot?"
          false
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
vagrantup-0.3.4 lib/vagrant/actions/vm/boot.rb
vagrantup-0.3.3 lib/vagrant/actions/vm/boot.rb
vagrantup-0.3.2 lib/vagrant/actions/vm/boot.rb
vagrantup-0.3.1 lib/vagrant/actions/vm/boot.rb
vagrantup-0.3.0 lib/vagrant/actions/vm/boot.rb
vagrant-0.3.4 lib/vagrant/actions/vm/boot.rb
vagrant-0.3.3 lib/vagrant/actions/vm/boot.rb
vagrant-0.3.2 lib/vagrant/actions/vm/boot.rb
vagrant-0.3.1 lib/vagrant/actions/vm/boot.rb
vagrant-0.3.0 lib/vagrant/actions/vm/boot.rb