diff --git a/lib/vagrant/actions/vm/up.rb b/lib/vagrant/actions/vm/up.rb index c117afc78..69091c1a9 100644 --- a/lib/vagrant/actions/vm/up.rb +++ b/lib/vagrant/actions/vm/up.rb @@ -21,6 +21,7 @@ module Vagrant def after_import update_dotfile setup_mac_address + check_guest_additions end def update_dotfile @@ -33,6 +34,19 @@ module Vagrant @runner.vm.network_adapters.first.mac_address = @runner.env.config.vm.base_mac @runner.vm.save 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 diff --git a/lib/vagrant/resource_logger.rb b/lib/vagrant/resource_logger.rb index 4d64ac644..82b37633c 100644 --- a/lib/vagrant/resource_logger.rb +++ b/lib/vagrant/resource_logger.rb @@ -61,19 +61,19 @@ module Vagrant @logger = self.class.singleton_logger(env) 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) - @@writer_lock.synchronize do - # We clear the line in case progress reports have been going - # out. - print(cl_reset) - logger.info("[#{resource}] #{message}") + # Once again flush the progress reporters since we probably + # cleared any existing ones. + flush_progress end - - # Once again flush the progress reporters since we probably - # cleared any existing ones. - flush_progress end # Sets a progress report for the resource that this logger diff --git a/lib/vagrant/util/translator.rb b/lib/vagrant/util/translator.rb index 89f651dc0..696440d23 100644 --- a/lib/vagrant/util/translator.rb +++ b/lib/vagrant/util/translator.rb @@ -6,7 +6,7 @@ module Vagrant class Translator @@strings = nil - class < 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 #--------------------------------------------------------------------- diff --git a/test/vagrant/actions/vm/up_test.rb b/test/vagrant/actions/vm/up_test.rb index 10056b2aa..a116e0188 100644 --- a/test/vagrant/actions/vm/up_test.rb +++ b/test/vagrant/actions/vm/up_test.rb @@ -69,6 +69,7 @@ class UpActionTest < Test::Unit::TestCase boot_seq = sequence("boot") @action.expects(:update_dotfile).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 end end diff --git a/test/vagrant/resource_logger_test.rb b/test/vagrant/resource_logger_test.rb index 2803da5cb..be7845152 100644 --- a/test/vagrant/resource_logger_test.rb +++ b/test/vagrant/resource_logger_test.rb @@ -76,11 +76,12 @@ class ResourceLoggerTest < Test::Unit::TestCase @instance.stubs(:cl_reset).returns("") end - should "log with the proper format" do - message = "bar" - @logger.expects(:info).with("[#{@resource}] #{message}").once - - @instance.info(message) + [:debug, :info, :error, :fatal].each do |method| + should "log with the proper format on #{method}" do + message = "bar" + @logger.expects(method).with("[#{@resource}] #{message}").once + @instance.send(method, message) + end end end