Class: VagrantPlugins::SyncedFolderNFSGuest::HostLinux::Cap::MountNFS

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-nfs_guest/hosts/linux/cap/mount_nfs.rb

Class Method Summary collapse

Class Method Details

.nfs_mount(environment, ui, id, ips, folders) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/vagrant-nfs_guest/hosts/linux/cap/mount_nfs.rb', line 7

def self.nfs_mount(environment, ui, id, ips, folders)
  folders.each do |name, opts|
    if opts[:type] != :nfs_guest
      next
    end

    ips.each do |ip|
      ui.detail(I18n.t("vagrant.actions.vm.share_folders.mounting_entry",
                       guestpath: opts[:guestpath],
                       hostpath: opts[:hostpath]))

      mount_options = opts.fetch(:mount_options, ["noatime"])
      nfs_options = mount_options.empty? ? "" : "-o #{mount_options.join(',')}"

      system("mkdir -p #{opts[:hostpath]}")
      mount_command = "sudo mount -t nfs #{nfs_options} '#{ip}:#{opts[:guestpath]}' '#{opts[:hostpath]}'"
      if system(mount_command)
        break
      end
    end
  end
end