From 20080839233a4847bcdf1a42e649d0f714f01149 Mon Sep 17 00:00:00 2001 From: dima Date: Fri, 1 May 2015 17:48:43 +0200 Subject: [PATCH] notification about box removing behaviour --- lib/vagrant-libvirt/action.rb | 8 ++++++++ .../action/remove_libvirt_image.rb | 20 +++++++++++++++++++ lib/vagrant-libvirt/plugin.rb | 6 +++++- 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 lib/vagrant-libvirt/action/remove_libvirt_image.rb diff --git a/lib/vagrant-libvirt/action.rb b/lib/vagrant-libvirt/action.rb index 98479a7..b2de400 100644 --- a/lib/vagrant-libvirt/action.rb +++ b/lib/vagrant-libvirt/action.rb @@ -8,6 +8,13 @@ module VagrantPlugins include Vagrant::Action::Builtin @logger = Log4r::Logger.new('vagrant_libvirt::action') + # remove image from libvirt storage pool + def self.remove_libvirt_image + Vagrant::Action::Builder.new.tap do |b| + b.use RemoveLibvirtImage + end + end + # This action is called to bring the box up from nothing. def self.action_up Vagrant::Action::Builder.new.tap do |b| @@ -331,6 +338,7 @@ module VagrantPlugins autoload :HaltDomain, action_root.join('halt_domain') autoload :HandleBoxImage, action_root.join('handle_box_image') autoload :HandleStoragePool, action_root.join('handle_storage_pool') + autoload :RemoveLibvirtImage, action_root.join('remove_libvirt_image') autoload :IsCreated, action_root.join('is_created') autoload :IsRunning, action_root.join('is_running') autoload :IsSuspended, action_root.join('is_suspended') diff --git a/lib/vagrant-libvirt/action/remove_libvirt_image.rb b/lib/vagrant-libvirt/action/remove_libvirt_image.rb new file mode 100644 index 0000000..554f0a7 --- /dev/null +++ b/lib/vagrant-libvirt/action/remove_libvirt_image.rb @@ -0,0 +1,20 @@ +require 'log4r' + +module VagrantPlugins + module ProviderLibvirt + module Action + class RemoveLibvirtImage + def initialize(app, env) + @logger = Log4r::Logger.new("vagrant_libvirt::action::remove_libvirt_image") + @app = app + end + + def call(env) + env[:ui].info("Vagrant-libvirt plugin removed box only from you LOCAL ~/.vagrant/boxes directory") + env[:ui].info("From libvirt storage pool you have to delete image manualy(virsh, virt-manager or by any other tool)") + @app.call(env) + end + end + end + end +end diff --git a/lib/vagrant-libvirt/plugin.rb b/lib/vagrant-libvirt/plugin.rb index 18e20ad..1dbb56c 100644 --- a/lib/vagrant-libvirt/plugin.rb +++ b/lib/vagrant-libvirt/plugin.rb @@ -32,6 +32,11 @@ module VagrantPlugins Provider end + action_hook(:remove_libvirt_image) do |hook| + hook.after Vagrant::Action::Builtin::BoxRemove, Action.remove_libvirt_image + end + + guest_capability('linux', 'mount_p9_shared_folder') do require_relative 'cap/mount_p9' Cap::MountP9 @@ -88,4 +93,3 @@ module VagrantPlugins end end end -