Sha256: fea4ea1e947b9768df1cbd1203b27cef6cddd68c1c0cc2bbe35adedcb13b6f49

Contents?: true

Size: 1.28 KB

Versions: 7

Compression:

Stored size: 1.28 KB

Contents

module Vagrant
  module Actions
    module VM
      class Boot < Base
        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(<<-error)
Failed to connect to VM! Failed to boot?
error
            end
          end
        end

        def collect_shared_folders
          # The root shared folder for the project
          ["vagrant-root", Env.root_path, Vagrant.config.vm.project_directory]
        end

        def boot
          logger.info "Booting VM..."
          @runner.vm.start(:headless, true)
        end

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

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

            if Vagrant::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

7 entries across 7 versions & 2 rubygems

Version Path
vagrantup-0.1.4 lib/vagrant/actions/vm/boot.rb
vagrantup-0.1.3 lib/vagrant/actions/vm/boot.rb
vagrantup-0.1.2 lib/vagrant/actions/vm/boot.rb
vagrant-0.1.4 lib/vagrant/actions/vm/boot.rb
vagrant-0.1.4.pre.a lib/vagrant/actions/vm/boot.rb
vagrant-0.1.3 lib/vagrant/actions/vm/boot.rb
vagrant-0.1.2 lib/vagrant/actions/vm/boot.rb