providers/virtualbox: style

This commit is contained in:
Mitchell Hashimoto 2014-10-23 09:12:41 -07:00
parent 7287604450
commit 2a8f74f54a
1 changed files with 14 additions and 11 deletions

View File

@ -316,7 +316,8 @@ module VagrantPlugins
def read_guest_ip(adapter_number)
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"
raise Vagrant::Errors::VirtualBoxGuestPropertyNotFound,
guest_property: "/VirtualBox/GuestInfo/Net/#{adapter_number}/V4/IP"
end
return ip
@ -562,16 +563,6 @@ 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.
@ -602,6 +593,18 @@ module VagrantPlugins
execute("showvminfo", uuid)
return true
end
protected
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
end
end
end