From 4d90fdfec583f1fef4b60533d8fd1cac1a42901f Mon Sep 17 00:00:00 2001 From: Brian Pitts Date: Sat, 3 May 2014 16:09:08 -0500 Subject: [PATCH 1/2] Check usability of nfs on host --- lib/vagrant/errors.rb | 4 ++++ plugins/synced_folders/nfs/synced_folder.rb | 11 +++-------- templates/locales/en.yml | 6 ++++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index eb0f78d0b..4204369f1 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -460,6 +460,10 @@ module Vagrant error_key(:nfs_no_valid_ids) end + class NFSNotSupported < VagrantError + error_key(:nfs_not_supported) + end + class NFSClientNotInstalledInGuest < VagrantError error_key(:nfs_client_not_installed_in_guest) end diff --git a/plugins/synced_folders/nfs/synced_folder.rb b/plugins/synced_folders/nfs/synced_folder.rb index fd10930e0..bcb9c7fd8 100644 --- a/plugins/synced_folders/nfs/synced_folder.rb +++ b/plugins/synced_folders/nfs/synced_folder.rb @@ -30,14 +30,9 @@ module VagrantPlugins if !machine.config.nfs.functional return false end - - # We don't currently support NFS on Windows - if Vagrant::Util::Platform.windows? - return false - end - - # NFS is always available - true + return true if machine.env.host.capability(:nfs_installed) + return false if !raise_error + raise Vagrant::Errors::NFSNotSupported end def prepare(machine, folders, opts) diff --git a/templates/locales/en.yml b/templates/locales/en.yml index a666fcbce..979b58372 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -813,6 +813,12 @@ en: No valid IDs were given to the NFS synced folder implementation to prune. This is an internal bug with Vagrant and an issue should be filed. + nfs_not_supported: |- + It appears your machine doesn't support NFS, or there is not an + adapter to enable NFS on this machine for Vagrant. Please verify + that `nfsd` is installed on your machine, and try again. If you're + on Windows, NFS isn't supported. If the problem persists, please + contact Vagrant support. nfs_client_not_installed_in_guest: |- No NFS client was detected as installed in your guest machine. This is required for NFS synced folders to work. In addition to this, Vagrant From 9f62216f87a437c0f57a9ac47ef275c3aba5a0c4 Mon Sep 17 00:00:00 2001 From: Brian Pitts Date: Sat, 3 May 2014 16:10:01 -0500 Subject: [PATCH 2/2] Remove check for nfs in config --- plugins/kernel_v2/config/vm.rb | 8 -------- templates/locales/en.yml | 6 ------ 2 files changed, 14 deletions(-) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 9eaf6f1a8..b498a7a4b 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -513,7 +513,6 @@ module VagrantPlugins end end - has_nfs = false used_guest_paths = Set.new @__synced_folders.each do |id, options| # If the shared folder is disabled then don't worry about validating it @@ -540,8 +539,6 @@ module VagrantPlugins end if options[:type] == :nfs - has_nfs = true - if options[:owner] || options[:group] # Owner/group don't work with NFS errors << I18n.t("vagrant.config.vm.shared_folder_nfs_owner_group", @@ -559,11 +556,6 @@ module VagrantPlugins end end - if has_nfs - errors << I18n.t("vagrant.config.vm.nfs_not_supported") if \ - !machine.env.host.capability(:nfs_installed) - end - # Validate networks has_fp_port_error = false fp_used = Set.new diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 979b58372..3eded4e70 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1224,12 +1224,6 @@ en: hostname_invalid_characters: |- The hostname set for the VM should only contain letters, numbers, hyphens or dots. It cannot start with a hyphen or dot. - nfs_not_supported: |- - It appears your machine doesn't support NFS, or there is not an - adapter to enable NFS on this machine for Vagrant. Please verify - that `nfsd` is installed on your machine, and try again. If you're - on Windows, NFS isn't supported. If the problem persists, please - contact Vagrant support. network_ip_ends_in_one: |- You assigned a static IP ending in ".1" to this machine. This is very often used by the router and can cause the