Class: VagrantVbguest::Command

Inherits:
Object
  • Object
show all
Includes:
VagrantPlugins::CommandUp::StartMixins, Helpers::Rebootable
Defined in:
lib/vagrant-vbguest/command.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers::Rebootable

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

Methods included from Helpers::VmCompatible

#communicate, #driver, included

Class Method Details

.synopsisObject

Show description when ‘vagrant list-commands` is triggered



77
78
79
# File 'lib/vagrant-vbguest/command.rb', line 77

def self.synopsis
  "plugin: vagrant-vbguest: install VirtualBox Guest Additions to the machine"
end

Instance Method Details

#executeObject

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



12
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
65
66
67
68
69
70
71
72
73
74
# File 'lib/vagrant-vbguest/command.rb', line 12

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] "\
                  "[--no-cleanup]"

    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

    opts.on("--no-cleanup", "Do not run cleanup tasks after installation. (for debugging)") do
      options[:no_cleanup] = true
    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