CheckGuestAdditions middleware

This commit is contained in:
Mitchell Hashimoto 2010-07-05 03:53:19 +02:00
parent de772a01ce
commit f205a747c9
4 changed files with 46 additions and 0 deletions

View File

@ -9,6 +9,7 @@ module Vagrant
use VM::Import
use VM::Persist
use VM::MatchMACAddress
use VM::CheckGuestAdditions
use VM::Customize
use VM::ForwardPorts
use VM::ShareFolders

View File

@ -0,0 +1,30 @@
module Vagrant
class Action
module VM
# 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.
class CheckGuestAdditions
def initialize(app, env)
@app = app
end
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.logger.error Translator.t(:vm_additions_not_detected)
elsif version != VirtualBox.version
env.logger.error Translator.t(:vm_additions_version_mismatch,
:guest_additions_version => version,
:virtualbox_version => VirtualBox.version)
end
# Continue
@app.call(env)
end
end
end
end
end

View File

@ -0,0 +1,9 @@
require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
class CheckGuestAdditionsVMActionTest < Test::Unit::TestCase
setup do
@klass = Vagrant::Action::VM::CheckGuestAdditions
end
# TODO: This isn't tested.
end

View File

@ -42,6 +42,8 @@ Gem::Specification.new do |s|
"lib/vagrant/action/vm/customize.rb",
"lib/vagrant/action/vm/forward_ports.rb",
"lib/vagrant/action/vm/import.rb",
"lib/vagrant/action/vm/match_mac_address.rb",
"lib/vagrant/action/vm/persist.rb",
"lib/vagrant/action/vm/share_folders.rb",
"lib/vagrant/actions/base.rb",
"lib/vagrant/actions/box/add.rb",
@ -130,6 +132,8 @@ Gem::Specification.new do |s|
"test/vagrant/action/vm/customize_test.rb",
"test/vagrant/action/vm/forward_ports_test.rb",
"test/vagrant/action/vm/import_test.rb",
"test/vagrant/action/vm/match_mac_address_test.rb",
"test/vagrant/action/vm/persist_test.rb",
"test/vagrant/action/vm/share_folders_test.rb",
"test/vagrant/action_test.rb",
"test/vagrant/actions/base_test.rb",
@ -216,6 +220,8 @@ Gem::Specification.new do |s|
"test/vagrant/action/vm/customize_test.rb",
"test/vagrant/action/vm/forward_ports_test.rb",
"test/vagrant/action/vm/import_test.rb",
"test/vagrant/action/vm/match_mac_address_test.rb",
"test/vagrant/action/vm/persist_test.rb",
"test/vagrant/action/vm/share_folders_test.rb",
"test/vagrant/action_test.rb",
"test/vagrant/actions/base_test.rb",