From ecea549e7fa770c4c225863c01703c8b5e7cdd97 Mon Sep 17 00:00:00 2001 From: Michal Sylwester Date: Mon, 30 Jan 2017 17:04:37 +0100 Subject: [PATCH] Be tolerant about drivers not supporting listing snapshots --- lib/vagrant-libvirt/action/destroy_domain.rb | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/vagrant-libvirt/action/destroy_domain.rb b/lib/vagrant-libvirt/action/destroy_domain.rb index 1656fb2..ce6ffbd 100644 --- a/lib/vagrant-libvirt/action/destroy_domain.rb +++ b/lib/vagrant-libvirt/action/destroy_domain.rb @@ -20,13 +20,19 @@ module VagrantPlugins libvirt_domain = env[:machine].provider.driver.connection.client.lookup_domain_by_uuid( env[:machine].id ) - libvirt_domain.list_snapshots.each do |name| - @logger.info("Deleting snapshot '#{name}'") - begin - libvirt_domain.lookup_snapshot_by_name(name).delete - rescue => e - raise Errors::DeleteSnapshotError, error_message: e.message + begin + libvirt_domain.list_snapshots.each do |name| + @logger.info("Deleting snapshot '#{name}'") + begin + libvirt_domain.lookup_snapshot_by_name(name).delete + rescue => e + raise Errors::DeleteSnapshotError, error_message: e.message + end end + rescue + # Some drivers (xen) don't support getting list of snapshots, + # not much can be done here about it + @logger.warn("Failed to get list of snapshots") end # must remove managed saves