From 766607db496c24e8efa4c1dcc36fcf7860a0ed11 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 9 Jan 2011 13:34:37 -0800 Subject: [PATCH] Raise an error message if host only networking is not supported --- lib/vagrant/systems/base.rb | 8 +++++++- templates/locales/en.yml | 11 +++++++++++ test/vagrant/systems/base_test.rb | 18 ++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 test/vagrant/systems/base_test.rb diff --git a/lib/vagrant/systems/base.rb b/lib/vagrant/systems/base.rb index 85cb66421..19c5e8ad9 100644 --- a/lib/vagrant/systems/base.rb +++ b/lib/vagrant/systems/base.rb @@ -15,6 +15,10 @@ module Vagrant # required by systems can and will change at any time. Any # changes will be noted on release notes.** class Base + class BaseError < Errors::VagrantError + error_namespace("vagrant.systems.base") + end + include Vagrant::Util # The VM which this system is tied to. @@ -64,7 +68,9 @@ module Vagrant # Prepares the system for host only networks. This is called # once prior to any `enable_host_only_network` calls. - def prepare_host_only_network; end + def prepare_host_only_network + raise BaseError, :_key => :unsupported_host_only + end # Setup the system by adding a new host only network. This # method should configure and bring up the interface for the diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 24f35af17..6c95489c6 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -460,6 +460,16 @@ en: running_puppetd: "Running Puppet agent..." systems: + base: + unsupported_host_only: |- + Host only networking is very distro-specific. Vagrant has support for many + distros built-in: Debian, Ubuntu, Gentoo, and RedHat. The distro of your VM + couldn't be detected, or isn't supported for host only networking. + + Most of the time this is simply due to the fact that no one has contributed + back the SSH commands necessary to set this up. Please report a bug and this + will be fixed for your distro. + linux: attempting_halt: "Attempting graceful shutdown of linux..." mount_fail: "Failed to mount shared folders. `vboxsf` was not available." @@ -469,5 +479,6 @@ en: that the NFS client software is properly installed, and consult any resources specific to the linux distro you're using for more information on how to do this. + solaris: attempting_halt: "Attempting graceful shutdown of solaris..." diff --git a/test/vagrant/systems/base_test.rb b/test/vagrant/systems/base_test.rb new file mode 100644 index 000000000..9ff07f21a --- /dev/null +++ b/test/vagrant/systems/base_test.rb @@ -0,0 +1,18 @@ +require "test_helper" + +class BaseSystemTest < Test::Unit::TestCase + setup do + @klass = Vagrant::Systems::Base + + @vm = mock("vm") + @instance = @klass.new(@vm) + end + + should "provide access to the VM" do + assert_equal @vm, @instance.vm + end + + should "error on preparing host only network" do + assert_raises(@klass::BaseError) { @instance.prepare_host_only_network } + end +end