Improved resilience of the VirtualBox driver delete_unused_host_only_networks 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
56c8b9269a
commit
9aecd5e1a4
|
@ -85,11 +85,18 @@ module VagrantPlugins
|
|||
|
||||
execute("list", "vms").split("\n").each do |line|
|
||||
if vm_name = line[/^".+?"\s+\{(.+?)\}$/, 1]
|
||||
info = execute("showvminfo", vm_name, "--machinereadable", retryable: true)
|
||||
info.split("\n").each do |line|
|
||||
if network_name = line[/^hostonlyadapter\d+="(.+?)"$/, 1]
|
||||
networks.delete(network_name)
|
||||
begin
|
||||
info = execute("showvminfo", vm_name, "--machinereadable", retryable: true)
|
||||
info.split("\n").each do |line|
|
||||
if network_name = line[/^hostonlyadapter\d+="(.+?)"$/, 1]
|
||||
networks.delete(network_name)
|
||||
end
|
||||
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
|
||||
|
|
|
@ -176,11 +176,18 @@ module VagrantPlugins
|
|||
|
||||
execute("list", "vms").split("\n").each do |line|
|
||||
if vm = line[/^".+?"\s+\{(.+?)\}$/, 1]
|
||||
info = execute("showvminfo", vm, "--machinereadable", retryable: true)
|
||||
info.split("\n").each do |line|
|
||||
if adapter = line[/^hostonlyadapter\d+="(.+?)"$/, 1]
|
||||
networks.delete(adapter)
|
||||
begin
|
||||
info = execute("showvminfo", vm, "--machinereadable", retryable: true)
|
||||
info.split("\n").each do |line|
|
||||
if adapter = line[/^hostonlyadapter\d+="(.+?)"$/, 1]
|
||||
networks.delete(adapter)
|
||||
end
|
||||
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
|
||||
|
|
|
@ -83,11 +83,18 @@ module VagrantPlugins
|
|||
|
||||
execute("list", "vms").split("\n").each do |line|
|
||||
if line =~ /^".+?"\s+\{(.+?)\}$/
|
||||
info = execute("showvminfo", $1.to_s, "--machinereadable", retryable: true)
|
||||
info.split("\n").each do |inner_line|
|
||||
if inner_line =~ /^hostonlyadapter\d+="(.+?)"$/
|
||||
networks.delete($1.to_s)
|
||||
begin
|
||||
info = execute("showvminfo", $1.to_s, "--machinereadable", retryable: true)
|
||||
info.split("\n").each do |inner_line|
|
||||
if inner_line =~ /^hostonlyadapter\d+="(.+?)"$/
|
||||
networks.delete($1.to_s)
|
||||
end
|
||||
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
|
||||
|
|
|
@ -180,11 +180,18 @@ module VagrantPlugins
|
|||
|
||||
execute("list", "vms", retryable: true).split("\n").each do |line|
|
||||
if line =~ /^".+?"\s+\{(.+?)\}$/
|
||||
info = execute("showvminfo", $1.to_s, "--machinereadable", retryable: true)
|
||||
info.split("\n").each do |inner_line|
|
||||
if inner_line =~ /^hostonlyadapter\d+="(.+?)"$/
|
||||
networks.delete($1.to_s)
|
||||
begin
|
||||
info = execute("showvminfo", $1.to_s, "--machinereadable", retryable: true)
|
||||
info.split("\n").each do |inner_line|
|
||||
if inner_line =~ /^hostonlyadapter\d+="(.+?)"$/
|
||||
networks.delete($1.to_s)
|
||||
end
|
||||
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
|
||||
|
|
|
@ -176,11 +176,18 @@ module VagrantPlugins
|
|||
|
||||
execute("list", "vms", retryable: true).split("\n").each do |line|
|
||||
if line =~ /^".+?"\s+\{(.+?)\}$/
|
||||
info = execute("showvminfo", $1.to_s, "--machinereadable", retryable: true)
|
||||
info.split("\n").each do |inner_line|
|
||||
if inner_line =~ /^hostonlyadapter\d+="(.+?)"$/
|
||||
networks.delete($1.to_s)
|
||||
begin
|
||||
info = execute("showvminfo", $1.to_s, "--machinereadable", retryable: true)
|
||||
info.split("\n").each do |inner_line|
|
||||
if inner_line =~ /^hostonlyadapter\d+="(.+?)"$/
|
||||
networks.delete($1.to_s)
|
||||
end
|
||||
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