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:
Paul Elliott
2020-04-28 16:22:34 +01:00
committed by GitHub
parent 9ea4aee83a
commit bde81a15a2
4 changed files with 35 additions and 18 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View 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