Only log warning when cleaning up disks

If a disk exists but isn't attached to a guest, don't attempt to remove
disk from guest.
This commit is contained in:
Brian Cain 2020-01-22 14:58:03 -08:00
parent 2e53c21fea
commit d215d9d785
No known key found for this signature in database
GPG Key ID: 9FC4639B2E4510A0

View File

@ -54,14 +54,14 @@ module VagrantPlugins
LOGGER.warn("Found disk not in Vagrantfile config: '#{d["name"]}'. Removing disk from guest #{machine.name}")
disk_info = get_port_and_device(vm_info, d["uuid"])
# TODO: add proper vagrant error here with values
if disk_info.empty?
raise Error, "could not determine device and port to remove disk"
end
machine.ui.warn("Disk '#{d["name"]}' no longer exists in Vagrant config. Removing and closing medium from guest...", prefix: true)
machine.provider.driver.remove_disk(disk_info[:port], disk_info[:device])
if disk_info.empty?
LOGGER.warn("Disk '#{d["name"]}' not attached to guest, but still exists.")
else
machine.provider.driver.remove_disk(disk_info[:port], disk_info[:device])
end
machine.provider.driver.close_medium(d["uuid"])
end
end