mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Remove NFS exports on domain destroy (#781)
Uncomment NFS prune action If the user has not configured NFS for any of the synced folders, then it is likely they are not expecting to be asked for a sudo password on destroy. Move the test for using NFS to a common module and include in both the preparing and pruning actions. Co-authored-by: Darragh Bailey <daragh.bailey@gmail.com>
This commit is contained in:
@@ -187,7 +187,7 @@ module VagrantPlugins
|
||||
b2.use Call, DestroyConfirm do |env2, b3|
|
||||
if env2[:result]
|
||||
b3.use ClearForwardedPorts
|
||||
# b3.use PruneNFSExports
|
||||
b3.use PruneNFSExports
|
||||
b3.use DestroyDomain
|
||||
b3.use DestroyNetworks
|
||||
b3.use ProvisionerCleanup
|
||||
|
||||
@@ -6,7 +6,7 @@ module VagrantPlugins
|
||||
module ProviderLibvirt
|
||||
module Action
|
||||
class PrepareNFSSettings
|
||||
include Vagrant::Action::Builtin::MixinSyncedFolders
|
||||
include VagrantPlugins::ProviderLibvirt::Util::Nfs
|
||||
|
||||
def initialize(app, _env)
|
||||
@app = app
|
||||
@@ -28,13 +28,6 @@ module VagrantPlugins
|
||||
end
|
||||
end
|
||||
|
||||
# We're using NFS if we have any synced folder with NFS configured. If
|
||||
# we are not using NFS we don't need to do the extra work to
|
||||
# populate these fields in the environment.
|
||||
def using_nfs?
|
||||
!!synced_folders(@machine)[:nfs]
|
||||
end
|
||||
|
||||
# Returns the IP address of the host
|
||||
#
|
||||
# @param [Machine] machine
|
||||
|
||||
@@ -3,11 +3,17 @@ module VagrantPlugins
|
||||
module ProviderLibvirt
|
||||
module Action
|
||||
class PruneNFSExports
|
||||
include VagrantPlugins::ProviderLibvirt::Util::Nfs
|
||||
|
||||
def initialize(app, _env)
|
||||
@app = app
|
||||
end
|
||||
|
||||
def call(env)
|
||||
@machine = env[:machine]
|
||||
|
||||
if using_nfs?
|
||||
@logger.info('Using NFS, prunning NFS settings from host')
|
||||
if env[:host]
|
||||
uuid = env[:machine].id
|
||||
# get all uuids
|
||||
@@ -18,6 +24,7 @@ module VagrantPlugins
|
||||
:nfs_prune, env[:machine].ui, uuids
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@app.call(env)
|
||||
end
|
||||
|
||||
17
lib/vagrant-libvirt/util/nfs.rb
Normal file
17
lib/vagrant-libvirt/util/nfs.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
module VagrantPlugins
|
||||
module ProviderLibvirt
|
||||
module Util
|
||||
module Nfs
|
||||
include Vagrant::Action::Builtin::MixinSyncedFolders
|
||||
|
||||
# We're using NFS if we have any synced folder with NFS configured. If
|
||||
# we are not using NFS we don't need to do the extra work to
|
||||
# populate these fields in the environment.
|
||||
def using_nfs?
|
||||
!!synced_folders(@machine)[:nfs]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user