Class: VagrantPlugins::SyncedFolderNFSGuest::Action::UnmountNFS
- Inherits:
-
Object
- Object
- VagrantPlugins::SyncedFolderNFSGuest::Action::UnmountNFS
- Defined in:
- lib/vagrant-nfs_guest/action/unmount_nfs.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ UnmountNFS
constructor
A new instance of UnmountNFS.
Constructor Details
#initialize(app, env) ⇒ UnmountNFS
Returns a new instance of UnmountNFS.
6 7 8 9 |
# File 'lib/vagrant-nfs_guest/action/unmount_nfs.rb', line 6 def initialize(app,env) @app = app @logger = Log4r::Logger.new("vagrant-nfs_guest::action::unmount_nfs") end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/vagrant-nfs_guest/action/unmount_nfs.rb', line 11 def call(env) @machine = env[:machine] if @machine.state.id == :running # unmount any host mounted NFS folders @machine.ui.info(I18n.t("vagrant_nfs_guest.actions.vm.nfs.unmounting")) folders = @machine.config.vm.synced_folders nfs_guest = false nfs_guest_folders = {} folders.each do |name, opts| if opts[:type] == :nfs_guest && opts[:disabled] == false nfs_guest = true opts[:hostpath] = File.(opts[:hostpath], env[:root_path]) if env[:force_halt] # If this is a force halt, force unmount the nfs shares. opts[:unmount_options] = opts.fetch(:unmount_options, []) << '-f' # We have to change the working dir if inside a hostmount to # prevent "No such file or directory - getcwd" errors. if Dir.pwd.start_with?(opts[:hostpath]) Dir.chdir("#{opts[:hostpath]}/..") end end nfs_guest_folders[name] = opts.dup end end if not nfs_guest return end @machine.env.host.capability(:nfs_unmount, @machine.ui, nfs_guest_folders) end @app.call(env) end |