From 022c1daec00d273fb62f71950d18ec3454708352 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 17 Mar 2013 22:33:02 -0700 Subject: [PATCH] Raise error if no hostonly network on VBox with NFS [GH-1437] --- CHANGELOG.md | 2 ++ lib/vagrant/errors.rb | 4 ++++ plugins/providers/virtualbox/action/prepare_nfs_settings.rb | 2 ++ templates/locales/en.yml | 4 ++++ 4 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42227fd1d..21308dd2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ BUG FIXES: - Fix minor issues with defaults of configuration of the shell provisioner. - Fix Puppet server using "host_name" instead of "hostname" [GH-1444] + - Raise a proper error if no hostonly network is found for NFS with + VirtualBox. [GH-1437] ## 1.1.0 (March 14, 2013) diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index 135d6ba35..fa286fb09 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -267,6 +267,10 @@ module Vagrant error_key(:nfs_no_host_ip) end + class NFSNoHostonlyNetwork < VagrantError + error_key(:nfs_no_hostonly_network) + end + class NoEnvironmentError < VagrantError error_key(:no_env) end diff --git a/plugins/providers/virtualbox/action/prepare_nfs_settings.rb b/plugins/providers/virtualbox/action/prepare_nfs_settings.rb index 742f34612..8af4d3586 100644 --- a/plugins/providers/virtualbox/action/prepare_nfs_settings.rb +++ b/plugins/providers/virtualbox/action/prepare_nfs_settings.rb @@ -12,6 +12,8 @@ module VagrantPlugins env[:nfs_host_ip] = read_host_ip(env[:machine]) env[:nfs_machine_ip] = read_machine_ip(env[:machine]) + + raise Errors::NFSNoHostonlyNetwork if !env[:nfs_machine_ip] end # Returns the IP address of the first host only network adapter diff --git a/templates/locales/en.yml b/templates/locales/en.yml index ff5cb468b..1d8f69b05 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -185,6 +185,10 @@ en: nfs_no_host_ip: |- No host IP was given to the Vagrant core NFS helper. This is an internal error that should be reported as a bug. + nfs_no_hostonly_network: |- + NFS requires a host-only network with a static IP to be created. + Please add a host-only network with a static IP to the machine + for NFS to work. no_env: |- A Vagrant environment is required to run this command. Run `vagrant init` to set one up in this directory, or change to a directory with a