Fix up NFS to use the new VirtualBox drivers

This commit is contained in:
Mitchell Hashimoto 2012-01-12 22:19:23 -08:00
parent 5c2bb9412d
commit 5630dc144d
2 changed files with 20 additions and 8 deletions

View File

@ -132,12 +132,17 @@ module Vagrant
# #
# @return [String] # @return [String]
def host_ip def host_ip
interface = @env[:vm].vm.network_adapters.find do |adapter| @env[:vm].driver.read_network_interfaces.each do |adapter, opts|
adapter.host_interface_object if opts[:type] == :hostonly
@env[:vm].driver.read_host_only_interfaces.each do |interface|
if interface[:name] == opts[:hostonly]
return interface[:ip]
end
end
end
end end
return nil if !interface nil
interface.host_interface_object.ip_address
end end
# Returns the IP address of the guest by looking at the first # Returns the IP address of the guest by looking at the first
@ -145,7 +150,13 @@ module Vagrant
# #
# @return [String] # @return [String]
def guest_ip def guest_ip
@env[:vm].config.vm.network_options[1][:ip] @env[:vm].config.vm.networks.each do |type, args|
if type == :hostonly && args[0].is_a?(String)
return args[0]
end
end
nil
end end
# Checks if there are any NFS enabled shared folders. # Checks if there are any NFS enabled shared folders.
@ -161,7 +172,7 @@ module Vagrant
def verify_settings def verify_settings
raise Errors::NFSHostRequired if @env[:host].nil? raise Errors::NFSHostRequired if @env[:host].nil?
raise Errors::NFSNotSupported if !@env[:host].nfs? raise Errors::NFSNotSupported if !@env[:host].nfs?
raise Errors::NFSNoHostNetwork if @env[:vm].config.vm.network_options.empty? raise Errors::NFSNoHostNetwork if !guest_ip
end end
end end
end end

View File

@ -450,8 +450,9 @@ en:
are auto-detected, but can be overridden with `config.vagrant.host`. are auto-detected, but can be overridden with `config.vagrant.host`.
There is currently no host class loaded. There is currently no host class loaded.
no_host_network: |- no_host_network: |-
NFS shared folders requires that host only networking is enabled. NFS shared folders requires that host only networking is enabled
Please enable host only networking via `config.vm.network`. with a static IP. Please enable host only network and assign a
static IP via `config.vm.network`.
not_supported: |- not_supported: |-
The host class is reporting that NFS is not supported by this host, The host class is reporting that NFS is not supported by this host,
or `nfsd` may not be installed. Please verify that `nfsd` is installed or `nfsd` may not be installed. Please verify that `nfsd` is installed