plugins/providers/virtualbox/action/prepare_nfs_settings.rb in vagrant-unbundled-1.9.7.1 vs plugins/providers/virtualbox/action/prepare_nfs_settings.rb in vagrant-unbundled-1.9.8.1
- old
+ new
@@ -1,5 +1,6 @@
+require "ipaddr"
require "vagrant/action/builtin/mixin_synced_folders"
module VagrantPlugins
module ProviderVirtualBox
module Action
@@ -54,9 +55,26 @@
# If we found a dynamic IP and we didn't include it in the
# machine_ip array yet, do so.
if dynamic_ip && !machine_ip.include?(dynamic_ip)
machine_ip.push(dynamic_ip)
+ end
+ end
+
+ if host_ip && !machine_ip.empty?
+ interface = @machine.provider.driver.read_host_only_interfaces.detect do |iface|
+ iface[:ip] == host_ip
+ end
+ host_ipaddr = IPAddr.new("#{host_ip}/#{interface.fetch(:netmask, "0.0.0.0")}")
+
+ case machine_ip
+ when String
+ machine_ip = nil if !host_ipaddr.include?(machine_ip)
+ when Array
+ machine_ip.delete_if do |m_ip|
+ !host_ipaddr.include?(m_ip)
+ end
+ machine_ip = nil if machine_ip.empty?
end
end
raise Vagrant::Errors::NFSNoHostonlyNetwork if !host_ip || !machine_ip