Class: Tenderloin::Actions::VM::Boot

Inherits:
Base
  • Object
show all
Defined in:
lib/tenderloin/actions/vm/boot.rb

Instance Attribute Summary

Attributes inherited from Base

#run_args, #runner

Instance Method Summary collapse

Methods inherited from Base

#cleanup, #initialize, #prepare, #rescue

Methods included from Util

#error_and_exit, included, #logger, #wrap_output

Constructor Details

This class inherits a constructor from Tenderloin::Actions::Base

Instance Method Details

#bootObject



25
26
27
28
29
# File 'lib/tenderloin/actions/vm/boot.rb', line 25

def boot
  logger.info "Booting VM..."

  @runner.fusion_vm.start(:headless => true)
end

#collect_shared_foldersObject



20
21
22
23
# File 'lib/tenderloin/actions/vm/boot.rb', line 20

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

#execute!Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/tenderloin/actions/vm/boot.rb', line 5

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

#wait_for_boot(sleeptime = 5) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/tenderloin/actions/vm/boot.rb', line 31

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

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

    if ip && Tenderloin::SSH.up?(ip)
      logger.info "VM booted and ready for use on IP: " + ip
      return true
    end

    sleep sleeptime
  end

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