Module: VagrantVbguest::CommandCommons

Includes:
Helpers::Rebootable
Included in:
Command
Defined in:
lib/vagrant-vbguest/command.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers::Rebootable

#reboot, #reboot!, #reboot?, #rebooted?

Methods included from Helpers::VmCompatible

#communicate, #driver

Class Method Details

.included(base) ⇒ Object



7
8
9
# File 'lib/vagrant-vbguest/command.rb', line 7

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#executeObject

Runs the vbguest installer on the VMs that are represented by this environment.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/vagrant-vbguest/command.rb', line 13

def execute
  options = {
    :_method => :run,
    :_rebootable => true,
    :auto_reboot => false
  }
  opts = OptionParser.new do |opts|
    opts.banner = "Usage: vagrant vbguest [vm-name] [--do start|rebuild|install] [--status] [-f|--force] [-b|--auto-reboot] [-R|--no-remote] [--iso VBoxGuestAdditions.iso]"
    opts.separator ""

    opts.on("--do COMMAND", [:start, :rebuild, :install], "Manually `start`, `rebuild` or `install` GuestAdditions.") do |command|
      options[:_method] = command
      options[:force] = true
    end

    opts.on("--status", "Print current GuestAdditions status and exit.") do
      options[:_method] = :status
      options[:_rebootable] = false
    end

    opts.on("-f", "--force", "Whether to force the installation. (Implied by --do start|rebuild|install)") do
      options[:force] = true
    end

    opts.on("--auto-reboot", "-b", "Allow rebooting the VM after installation. (when GuestAdditions won't start)") do
      options[:auto_reboot] = true
    end

    opts.on("--no-remote", "-R", "Do not attempt do download the iso file from a webserver") do
      options[:no_remote] = true
    end

    opts.on("--iso file_or_uri", "Full path or URI to the VBoxGuestAdditions.iso") do |file_or_uri|
      options[:iso_path] = file_or_uri
    end

    build_start_options(opts, options)
  end


  argv = parse_options(opts)
  return if !argv

  if argv.empty?
    with_target_vms(nil) { |vm| execute_on_vm(vm, options) }
  else
    argv.each do |vm_name|
      with_target_vms(vm_name) { |vm| execute_on_vm(vm, options) }
    end
  end

end