Improved resilience of the VirtualBox driver read_used_ports function by

ignoring VMs that may have been deleted between the calls to
'vboxmanage list vms' and 'vboxmanage showvminfo'
This commit is contained in:
nico.vanelslande 2016-05-31 14:51:56 +01:00 committed by Brian Cain
parent 6673c14916
commit 56c8b9269a
5 changed files with 46 additions and 11 deletions

View File

@ -422,8 +422,15 @@ module VagrantPlugins
# Ignore our own used ports
next if uuid == @uuid
read_forwarded_ports(uuid, true).each do |_, _, hostport, _|
ports << hostport
begin
read_forwarded_ports(uuid, true).each do |_, _, hostport, _|
ports << hostport
end
rescue Vagrant::Errors::VBoxManageError => e
raise if !e.extra_data[:stderr].include?("VBOX_E_OBJECT_NOT_FOUND")
# VirtualBox could not find the vm. It may have been deleted
# by another process after we called 'vboxmanage list vms'? Ignore this error.
end
end
end

View File

@ -525,8 +525,15 @@ module VagrantPlugins
# Ignore our own used ports
next if uuid == @uuid
read_forwarded_ports(uuid, true).each do |_, _, hostport, _|
ports << hostport
begin
read_forwarded_ports(uuid, true).each do |_, _, hostport, _|
ports << hostport
end
rescue Vagrant::Errors::VBoxManageError => e
raise if !e.extra_data[:stderr].include?("VBOX_E_OBJECT_NOT_FOUND")
# VirtualBox could not find the vm. It may have been deleted
# by another process after we called 'vboxmanage list vms'? Ignore this error.
end
end
end

View File

@ -458,8 +458,15 @@ module VagrantPlugins
# Ignore our own used ports
next if uuid == @uuid
read_forwarded_ports(uuid, true).each do |_, _, hostport, _|
ports << hostport
begin
read_forwarded_ports(uuid, true).each do |_, _, hostport, _|
ports << hostport
end
rescue Vagrant::Errors::VBoxManageError => e
raise if !e.extra_data[:stderr].include?("VBOX_E_OBJECT_NOT_FOUND")
# VirtualBox could not find the vm. It may have been deleted
# by another process after we called 'vboxmanage list vms'? Ignore this error.
end
end
end

View File

@ -569,8 +569,15 @@ module VagrantPlugins
# Ignore our own used ports
next if uuid == @uuid
read_forwarded_ports(uuid, true).each do |_, _, hostport, _|
ports << hostport
begin
read_forwarded_ports(uuid, true).each do |_, _, hostport, _|
ports << hostport
end
rescue Vagrant::Errors::VBoxManageError => e
raise if !e.extra_data[:stderr].include?("VBOX_E_OBJECT_NOT_FOUND")
# VirtualBox could not find the vm. It may have been deleted
# by another process after we called 'vboxmanage list vms'? Ignore this error.
end
end
end

View File

@ -567,9 +567,16 @@ module VagrantPlugins
# Ignore our own used ports
next if uuid == @uuid
read_forwarded_ports(uuid, true).each do |_, _, hostport, _, hostip|
hostip = '*' if hostip.nil? || hostip.empty?
used_ports[hostport].add?(hostip)
begin
read_forwarded_ports(uuid, true).each do |_, _, hostport, _, hostip|
hostip = '*' if hostip.nil? || hostip.empty?
used_ports[hostport].add?(hostip)
end
rescue Vagrant::Errors::VBoxManageError => e
raise if !e.extra_data[:stderr].include?("VBOX_E_OBJECT_NOT_FOUND")
# VirtualBox could not find the vm. It may have been deleted
# by another process after we called 'vboxmanage list vms'? Ignore this error.
end
end
end