Merge pull request #4671 from jramnani/fix/master/nfs_exports_file_for_freebsd_guests

Fix #4658. Bad NFS exports file on OS X & BSD hosts.
This commit is contained in:
Mitchell Hashimoto 2014-10-23 09:12:00 -07:00
commit 7287604450
5 changed files with 75 additions and 4 deletions

View File

@ -269,7 +269,12 @@ module VagrantPlugins
end
def read_guest_ip(adapter_number)
read_guest_property("/VirtualBox/GuestInfo/Net/#{adapter_number}/V4/IP")
ip = read_guest_property("/VirtualBox/GuestInfo/Net/#{adapter_number}/V4/IP")
if !valid_ip_address?(ip)
raise Vagrant::Errors::VirtualBoxGuestPropertyNotFound, guest_property: "/VirtualBox/GuestInfo/Net/#{adapter_number}/V4/IP"
end
return ip
end
def read_guest_property(property)
@ -500,6 +505,16 @@ module VagrantPlugins
end
end
def valid_ip_address?(ip)
# Filter out invalid IP addresses
# GH-4658 VirtualBox can report an IP address of 0.0.0.0 for FreeBSD guests.
if ip == "0.0.0.0"
return false
else
return true
end
end
def verify!
# This command sometimes fails if kernel drivers aren't properly loaded
# so we just run the command and verify that it succeeded.

View File

@ -274,7 +274,12 @@ module VagrantPlugins
end
def read_guest_ip(adapter_number)
read_guest_property("/VirtualBox/GuestInfo/Net/#{adapter_number}/V4/IP")
ip = read_guest_property("/VirtualBox/GuestInfo/Net/#{adapter_number}/V4/IP")
if !valid_ip_address?(ip)
raise Vagrant::Errors::VirtualBoxGuestPropertyNotFound, guest_property: "/VirtualBox/GuestInfo/Net/#{adapter_number}/V4/IP"
end
return ip
end
def read_guest_property(property)
@ -510,6 +515,16 @@ module VagrantPlugins
end
end
def valid_ip_address?(ip)
# Filter out invalid IP addresses
# GH-4658 VirtualBox can report an IP address of 0.0.0.0 for FreeBSD guests.
if ip == "0.0.0.0"
return false
else
return true
end
end
def verify!
# This command sometimes fails if kernel drivers aren't properly loaded
# so we just run the command and verify that it succeeded.

View File

@ -305,7 +305,12 @@ module VagrantPlugins
end
def read_guest_ip(adapter_number)
read_guest_property("/VirtualBox/GuestInfo/Net/#{adapter_number}/V4/IP")
ip = read_guest_property("/VirtualBox/GuestInfo/Net/#{adapter_number}/V4/IP")
if !valid_ip_address?(ip)
raise Vagrant::Errors::VirtualBoxGuestPropertyNotFound, guest_property: "/VirtualBox/GuestInfo/Net/#{adapter_number}/V4/IP"
end
return ip
end
def read_guest_property(property)
@ -541,6 +546,16 @@ module VagrantPlugins
end
end
def valid_ip_address?(ip)
# Filter out invalid IP addresses
# GH-4658 VirtualBox can report an IP address of 0.0.0.0 for FreeBSD guests.
if ip == "0.0.0.0"
return false
else
return true
end
end
def verify!
# This command sometimes fails if kernel drivers aren't properly loaded
# so we just run the command and verify that it succeeded.

View File

@ -314,7 +314,12 @@ module VagrantPlugins
end
def read_guest_ip(adapter_number)
read_guest_property("/VirtualBox/GuestInfo/Net/#{adapter_number}/V4/IP")
ip = read_guest_property("/VirtualBox/GuestInfo/Net/#{adapter_number}/V4/IP")
if !valid_ip_address?(ip)
raise Vagrant::Errors::VirtualBoxGuestPropertyNotFound, guest_property: "/VirtualBox/GuestInfo/Net/#{adapter_number}/V4/IP"
end
return ip
end
def read_guest_property(property)
@ -557,6 +562,16 @@ module VagrantPlugins
end
end
def valid_ip_address?(ip)
# Filter out invalid IP addresses
# GH-4658 VirtualBox can report an IP address of 0.0.0.0 for FreeBSD guests.
if ip == "0.0.0.0"
return false
else
return true
end
end
def verify!
# This command sometimes fails if kernel drivers aren't properly loaded
# so we just run the command and verify that it succeeded.

View File

@ -38,5 +38,16 @@ shared_examples "a version 4.x virtualbox driver" do |options|
expect(value).to eq("127.1.2.3")
end
it "does not accept 0.0.0.0 as a valid IP address" do
key = "/VirtualBox/GuestInfo/Net/1/V4/IP"
expect(subprocess).to receive(:execute).
with("VBoxManage", "guestproperty", "get", uuid, key, an_instance_of(Hash)).
and_return(subprocess_result(stdout: "Value: 0.0.0.0"))
expect { subject.read_guest_ip(1) }.
to raise_error Vagrant::Errors::VirtualBoxGuestPropertyNotFound
end
end
end