diff --git a/lib/vagrant-libvirt/action.rb b/lib/vagrant-libvirt/action.rb index 820a84a..5894f56 100644 --- a/lib/vagrant-libvirt/action.rb +++ b/lib/vagrant-libvirt/action.rb @@ -183,11 +183,17 @@ module VagrantPlugins next end - b2.use ClearForwardedPorts - # b2.use PruneNFSExports - b2.use DestroyDomain - b2.use DestroyNetworks - b2.use ProvisionerCleanup + b2.use Call, DestroyConfirm do |env2, b3| + if env2[:result] + b3.use ClearForwardedPorts + # b3.use PruneNFSExports + b3.use DestroyDomain + b3.use DestroyNetworks + b3.use ProvisionerCleanup + else + b3.use MessageWillNotDestroy + end + end end end end @@ -332,6 +338,7 @@ module VagrantPlugins autoload :MessageNotCreated, action_root.join('message_not_created') autoload :MessageNotRunning, action_root.join('message_not_running') autoload :MessageNotSuspended, action_root.join('message_not_suspended') + autoload :MessageWillNotDestroy, action_root.join('message_will_not_destroy') autoload :RemoveStaleVolume, action_root.join('remove_stale_volume') diff --git a/lib/vagrant-libvirt/action/message_will_not_destroy.rb b/lib/vagrant-libvirt/action/message_will_not_destroy.rb new file mode 100644 index 0000000..8d31dbd --- /dev/null +++ b/lib/vagrant-libvirt/action/message_will_not_destroy.rb @@ -0,0 +1,17 @@ +module VagrantPlugins + module ProviderLibvirt + module Action + class MessageWillNotDestroy + def initialize(app, env) + @app = app + end + + def call(env) + env[:ui].info I18n.t("vagrant.commands.destroy.will_not_destroy", + name: env[:machine].name) + @app.call(env) + end + end + end + end +end