[DRE-commits] [vagrant-libvirt] 99/104: Delete any snapshots when destroying a domain
Antonio Terceiro
terceiro at moszumanska.debian.org
Sun Apr 24 13:55:52 UTC 2016
This is an automated email from the git hooks/post-receive script.
terceiro pushed a commit to annotated tag 0.0.11
in repository vagrant-libvirt.
commit 69f97cf33a0700974b22a723d8051d8f22e8a105
Author: Brian Pitts <brian at polibyte.com>
Date: Sat Oct 19 13:50:28 2013 -0500
Delete any snapshots when destroying a domain
---
lib/vagrant-libvirt/action/destroy_domain.rb | 14 ++++++++++++++
lib/vagrant-libvirt/errors.rb | 4 ++++
locales/en.yml | 2 ++
3 files changed, 20 insertions(+)
diff --git a/lib/vagrant-libvirt/action/destroy_domain.rb b/lib/vagrant-libvirt/action/destroy_domain.rb
index e00daf6..62c56c3 100644
--- a/lib/vagrant-libvirt/action/destroy_domain.rb
+++ b/lib/vagrant-libvirt/action/destroy_domain.rb
@@ -13,6 +13,20 @@ module VagrantPlugins
# Destroy the server, remove the tracking ID
env[:ui].info(I18n.t("vagrant_libvirt.destroy_domain"))
+ # Must delete any snapshots before domain can be destroyed
+ # Fog libvirt currently doesn't support snapshots. Use
+ # ruby-libvirt client directly. Note this is racy, see
+ # http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSnapshotListNames
+ libvirt_domain = env[:libvirt_compute].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
+ end
+ end
+
domain = env[:libvirt_compute].servers.get(env[:machine].id.to_s)
domain.destroy(:destroy_volumes => true)
env[:machine].id = nil
diff --git a/lib/vagrant-libvirt/errors.rb b/lib/vagrant-libvirt/errors.rb
index 0c754b5..4758083 100644
--- a/lib/vagrant-libvirt/errors.rb
+++ b/lib/vagrant-libvirt/errors.rb
@@ -118,6 +118,10 @@ module VagrantPlugins
error_key(:no_ip_address_error)
end
+ class DeleteSnapshotError < VagrantLibvirtError
+ error_key(:delete_snapshot_error)
+ end
+
end
end
end
diff --git a/locales/en.yml b/locales/en.yml
index e19438c..e7ea0db 100644
--- a/locales/en.yml
+++ b/locales/en.yml
@@ -115,6 +115,8 @@ en:
Error while setting up autostart on network: %{error_message}.
destroy_network_error: |-
Error while removing network %{network_name}. %{error_message}.
+ delete_snapshot_error: |-
+ Error while deleting snapshot: %{error_message}.
states:
short_paused: |-
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/vagrant-libvirt.git
More information about the Pkg-ruby-extras-commits
mailing list