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|
|
execute("list", "vms").split("\n").each do |line|
|
||||||
if vm_name = line[/^".+?"\s+\{(.+?)\}$/, 1]
|
if vm_name = line[/^".+?"\s+\{(.+?)\}$/, 1]
|
||||||
info = execute("showvminfo", vm_name, "--machinereadable", retryable: true)
|
begin
|
||||||
info.split("\n").each do |line|
|
info = execute("showvminfo", vm_name, "--machinereadable", retryable: true)
|
||||||
if network_name = line[/^hostonlyadapter\d+="(.+?)"$/, 1]
|
info.split("\n").each do |line|
|
||||||
networks.delete(network_name)
|
if network_name = line[/^hostonlyadapter\d+="(.+?)"$/, 1]
|
||||||
|
networks.delete(network_name)
|
||||||
|
end
|
||||||
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -176,11 +176,18 @@ module VagrantPlugins
|
||||||
|
|
||||||
execute("list", "vms").split("\n").each do |line|
|
execute("list", "vms").split("\n").each do |line|
|
||||||
if vm = line[/^".+?"\s+\{(.+?)\}$/, 1]
|
if vm = line[/^".+?"\s+\{(.+?)\}$/, 1]
|
||||||
info = execute("showvminfo", vm, "--machinereadable", retryable: true)
|
begin
|
||||||
info.split("\n").each do |line|
|
info = execute("showvminfo", vm, "--machinereadable", retryable: true)
|
||||||
if adapter = line[/^hostonlyadapter\d+="(.+?)"$/, 1]
|
info.split("\n").each do |line|
|
||||||
networks.delete(adapter)
|
if adapter = line[/^hostonlyadapter\d+="(.+?)"$/, 1]
|
||||||
|
networks.delete(adapter)
|
||||||
|
end
|
||||||
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -83,11 +83,18 @@ module VagrantPlugins
|
||||||
|
|
||||||
execute("list", "vms").split("\n").each do |line|
|
execute("list", "vms").split("\n").each do |line|
|
||||||
if line =~ /^".+?"\s+\{(.+?)\}$/
|
if line =~ /^".+?"\s+\{(.+?)\}$/
|
||||||
info = execute("showvminfo", $1.to_s, "--machinereadable", retryable: true)
|
begin
|
||||||
info.split("\n").each do |inner_line|
|
info = execute("showvminfo", $1.to_s, "--machinereadable", retryable: true)
|
||||||
if inner_line =~ /^hostonlyadapter\d+="(.+?)"$/
|
info.split("\n").each do |inner_line|
|
||||||
networks.delete($1.to_s)
|
if inner_line =~ /^hostonlyadapter\d+="(.+?)"$/
|
||||||
|
networks.delete($1.to_s)
|
||||||
|
end
|
||||||
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -180,11 +180,18 @@ module VagrantPlugins
|
||||||
|
|
||||||
execute("list", "vms", retryable: true).split("\n").each do |line|
|
execute("list", "vms", retryable: true).split("\n").each do |line|
|
||||||
if line =~ /^".+?"\s+\{(.+?)\}$/
|
if line =~ /^".+?"\s+\{(.+?)\}$/
|
||||||
info = execute("showvminfo", $1.to_s, "--machinereadable", retryable: true)
|
begin
|
||||||
info.split("\n").each do |inner_line|
|
info = execute("showvminfo", $1.to_s, "--machinereadable", retryable: true)
|
||||||
if inner_line =~ /^hostonlyadapter\d+="(.+?)"$/
|
info.split("\n").each do |inner_line|
|
||||||
networks.delete($1.to_s)
|
if inner_line =~ /^hostonlyadapter\d+="(.+?)"$/
|
||||||
|
networks.delete($1.to_s)
|
||||||
|
end
|
||||||
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
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -176,11 +176,18 @@ module VagrantPlugins
|
||||||
|
|
||||||
execute("list", "vms", retryable: true).split("\n").each do |line|
|
execute("list", "vms", retryable: true).split("\n").each do |line|
|
||||||
if line =~ /^".+?"\s+\{(.+?)\}$/
|
if line =~ /^".+?"\s+\{(.+?)\}$/
|
||||||
info = execute("showvminfo", $1.to_s, "--machinereadable", retryable: true)
|
begin
|
||||||
info.split("\n").each do |inner_line|
|
info = execute("showvminfo", $1.to_s, "--machinereadable", retryable: true)
|
||||||
if inner_line =~ /^hostonlyadapter\d+="(.+?)"$/
|
info.split("\n").each do |inner_line|
|
||||||
networks.delete($1.to_s)
|
if inner_line =~ /^hostonlyadapter\d+="(.+?)"$/
|
||||||
|
networks.delete($1.to_s)
|
||||||
|
end
|
||||||
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue