Warning if guest additions version mismatches [closes GH-96]
This commit is contained in:
parent
3532f6368c
commit
3be88f44fa
|
@ -21,6 +21,7 @@ module Vagrant
|
||||||
def after_import
|
def after_import
|
||||||
update_dotfile
|
update_dotfile
|
||||||
setup_mac_address
|
setup_mac_address
|
||||||
|
check_guest_additions
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_dotfile
|
def update_dotfile
|
||||||
|
@ -33,6 +34,19 @@ module Vagrant
|
||||||
@runner.vm.network_adapters.first.mac_address = @runner.env.config.vm.base_mac
|
@runner.vm.network_adapters.first.mac_address = @runner.env.config.vm.base_mac
|
||||||
@runner.vm.save
|
@runner.vm.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_guest_additions
|
||||||
|
# Use the raw interface for now, while the virtualbox gem
|
||||||
|
# doesn't support guest properties (due to cross platform issues)
|
||||||
|
version = @runner.vm.interface.get_guest_property_value("/VirtualBox/GuestAdd/Version")
|
||||||
|
if version.empty?
|
||||||
|
logger.error Translator.t(:vm_additions_not_detected)
|
||||||
|
elsif version != VirtualBox.version
|
||||||
|
logger.error Translator.t(:vm_additions_version_mismatch,
|
||||||
|
:guest_additions_version => version,
|
||||||
|
:virtualbox_version => VirtualBox.version)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -61,19 +61,19 @@ module Vagrant
|
||||||
@logger = self.class.singleton_logger(env)
|
@logger = self.class.singleton_logger(env)
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: The other logging methods.
|
[:debug, :info, :error, :fatal].each do |method|
|
||||||
|
define_method(method) do |message|
|
||||||
|
@@writer_lock.synchronize do
|
||||||
|
# We clear the line in case progress reports have been going
|
||||||
|
# out.
|
||||||
|
print(cl_reset)
|
||||||
|
logger.send(method, "[#{resource}] #{message}")
|
||||||
|
end
|
||||||
|
|
||||||
def info(message)
|
# Once again flush the progress reporters since we probably
|
||||||
@@writer_lock.synchronize do
|
# cleared any existing ones.
|
||||||
# We clear the line in case progress reports have been going
|
flush_progress
|
||||||
# out.
|
|
||||||
print(cl_reset)
|
|
||||||
logger.info("[#{resource}] #{message}")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Once again flush the progress reporters since we probably
|
|
||||||
# cleared any existing ones.
|
|
||||||
flush_progress
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sets a progress report for the resource that this logger
|
# Sets a progress report for the resource that this logger
|
||||||
|
|
|
@ -6,7 +6,7 @@ module Vagrant
|
||||||
class Translator
|
class Translator
|
||||||
@@strings = nil
|
@@strings = nil
|
||||||
|
|
||||||
class <<self
|
class << self
|
||||||
# Resets the internal strings hash to nil, forcing a reload on the next
|
# Resets the internal strings hash to nil, forcing a reload on the next
|
||||||
# access of {strings}.
|
# access of {strings}.
|
||||||
def reset!
|
def reset!
|
||||||
|
@ -32,4 +32,4 @@ module Vagrant
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,6 +40,26 @@
|
||||||
Path: <%= data["path"] %>
|
Path: <%= data["path"] %>
|
||||||
Created at: <%= Time.at(data["created_at"]) %>
|
Created at: <%= Time.at(data["created_at"]) %>
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------
|
||||||
|
# CATEGORY: Warning Messages
|
||||||
|
#---------------------------------------------------------------------
|
||||||
|
:vm_additions_not_detected: |-
|
||||||
|
WARNING!
|
||||||
|
No guest additions were detected on the base box for this VM! Guest
|
||||||
|
additions are required for forwarded ports, shared folders, host only
|
||||||
|
networking, and more. If SSH fails on this machine, please install
|
||||||
|
the guest additions and repackage the box to continue.
|
||||||
|
:vm_additions_version_mismatch: |-
|
||||||
|
WARNING!
|
||||||
|
The guest additions on this VM do not match the install version of
|
||||||
|
VirtualBox! This often causes things such as forwared ports, shared
|
||||||
|
folders, and more to not work properly. If any of those things fail on
|
||||||
|
this machine, please update the guest additions and repackage the
|
||||||
|
box.
|
||||||
|
|
||||||
|
Guest Additions Version: <%= guest_additions_version %>
|
||||||
|
VirtualBox Version: <%= virtualbox_version %>
|
||||||
|
|
||||||
#---------------------------------------------------------------------
|
#---------------------------------------------------------------------
|
||||||
# CATEGORY: Error Messages
|
# CATEGORY: Error Messages
|
||||||
#---------------------------------------------------------------------
|
#---------------------------------------------------------------------
|
||||||
|
|
|
@ -69,6 +69,7 @@ class UpActionTest < Test::Unit::TestCase
|
||||||
boot_seq = sequence("boot")
|
boot_seq = sequence("boot")
|
||||||
@action.expects(:update_dotfile).once.in_sequence(boot_seq)
|
@action.expects(:update_dotfile).once.in_sequence(boot_seq)
|
||||||
@action.expects(:setup_mac_address).once.in_sequence(boot_seq)
|
@action.expects(:setup_mac_address).once.in_sequence(boot_seq)
|
||||||
|
@action.expects(:check_guest_additions).once.in_sequence(boot_seq)
|
||||||
@action.after_import
|
@action.after_import
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -76,11 +76,12 @@ class ResourceLoggerTest < Test::Unit::TestCase
|
||||||
@instance.stubs(:cl_reset).returns("")
|
@instance.stubs(:cl_reset).returns("")
|
||||||
end
|
end
|
||||||
|
|
||||||
should "log with the proper format" do
|
[:debug, :info, :error, :fatal].each do |method|
|
||||||
message = "bar"
|
should "log with the proper format on #{method}" do
|
||||||
@logger.expects(:info).with("[#{@resource}] #{message}").once
|
message = "bar"
|
||||||
|
@logger.expects(method).with("[#{@resource}] #{message}").once
|
||||||
@instance.info(message)
|
@instance.send(method, message)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue