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:
parent
6673c14916
commit
56c8b9269a
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue