Class: Vagrant::Action::VM::CheckGuestAdditions

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant/action/vm/check_guest_additions.rb

Overview

Middleware which verifies that the VM has the proper guest additions installed and prints a warning if they're not detected or if the version does not match the installed VirtualBox version.

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ CheckGuestAdditions

Returns a new instance of CheckGuestAdditions.



8
9
10
# File 'lib/vagrant/action/vm/check_guest_additions.rb', line 8

def initialize(app, env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/vagrant/action/vm/check_guest_additions.rb', line 12

def call(env)
  # Use the raw interface for now, while the virtualbox gem
  # doesn't support guest properties (due to cross platform issues)
  version = env["vm"].vm.interface.get_guest_property_value("/VirtualBox/GuestAdd/Version")
  if version.empty?
    env.ui.warn I18n.t("vagrant.actions.vm.check_guest_additions.not_detected")
  elsif version != VirtualBox.version
    env.ui.warn(I18n.t("vagrant.actions.vm.check_guest_additions.version_mismatch",
                :guest_version => version,
                :virtualbox_version => VirtualBox.version))
  end

  # Continue
  @app.call(env)
end