Module: VirtualBox::VM::Lifecycle

Included in:
VirtualBox::VM
Defined in:
lib/virtual_box/vm/lifecycle.rb

Overview

Mix-in for the VM class covering life-cycle management.

Instance Method Summary collapse

Instance Method Details

#start(options = {}) ⇒ Object

Starts the virtual machine.

The following options are supported:

:gui:: if set to true, VMs will be started in a GUI; this is intended to
       help debugging
:rdp:: if set to true, RDP support will be enabled; by default, RDP
       support is disabled; VirtualBox OSE does not support RDP, so the
       call will raise an exception


24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/virtual_box/vm/lifecycle.rb', line 24

def start(options = {})
  if options[:gui]
    command = "VBoxManage startvm #{uuid} --type gui"
  else
    command = "VBoxHeadless --startvm #{uuid}"
  end      
    
  if VirtualBox.ose?
    raise 'Cannot enable RDP support on VirtualBox OSE' if options[:rdp]
  else
    command += " --vrdp #{options[:rdp] ? 'on' : 'off'}"
  end
  VirtualBox.shell_command(command)[:status] == 0
end