Class: VagrantPlugins::ProviderLibvirt::Action::PruneNFSExports

Inherits:
Object
  • Object
show all
Includes:
Util::Nfs
Defined in:
lib/vagrant-libvirt/action/prune_nfs_exports.rb

Instance Method Summary collapse

Methods included from Util::Nfs

#using_nfs?

Constructor Details

#initialize(app, _env) ⇒ PruneNFSExports

Returns a new instance of PruneNFSExports.


10
11
12
13
# File 'lib/vagrant-libvirt/action/prune_nfs_exports.rb', line 10

def initialize(app, _env)
  @logger = Log4r::Logger.new('vagrant_libvirt::action::prune_nfs_exports')
  @app = app
end

Instance Method Details

#call(env) ⇒ Object


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/vagrant-libvirt/action/prune_nfs_exports.rb', line 15

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
      uuids = env[:machine].provider.driver.connection.servers.all.map(&:id)
      # not exiisted in array will removed from nfs
      uuids.delete(uuid)
      env[:host].capability(
        :nfs_prune, env[:machine].ui, uuids
      )
    end
  end

  @app.call(env)
end