Fix allow_existing for disks against newer versions of libvirt. (#1507)

When running vagrant-libvirt on an up-to-date Debian unstable with
libvirt 8.4.0 the expected error message doesn't contain the full
path any more.
This commit is contained in:
anonym 2022-06-08 18:21:35 +00:00 committed by GitHub
parent 9885e58c21
commit 1ed088924a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -151,9 +151,11 @@ module VagrantPlugins
rescue Libvirt::Error => e rescue Libvirt::Error => e
# It is hard to believe that e contains just a string # It is hard to believe that e contains just a string
# and no useful error code! # and no useful error code!
msg = "Call to virStorageVolCreateXML failed: " + msgs = [disk[:name], disk[:absolute_path]].map do |name|
"storage volume '#{disk[:absolute_path]}' exists already" "Call to virStorageVolCreateXML failed: " +
if e.message == msg and disk[:allow_existing] "storage volume '#{name}' exists already"
end
if msgs.include?(e.message) and disk[:allow_existing]
disk[:preexisting] = true disk[:preexisting] = true
else else
raise Errors::FogCreateDomainVolumeError, raise Errors::FogCreateDomainVolumeError,