Sha256: 385fabd4cb34733ba4486857726205dd2db71abeb6560b9e502bda90660ec3f6

Contents?: true

Size: 1.27 KB

Versions: 6

Compression:

Stored size: 1.27 KB

Contents

require "vagrant/util/retryable"

module VagrantPlugins
  module GuestLinux
    module Cap
      class MountNFS
        extend Vagrant::Util::Retryable

        def self.mount_nfs_folder(machine, ip, folders)
          folders.each do |name, opts|
            # Expand the guest path so we can handle things like "~/vagrant"
            expanded_guest_path = machine.guest.capability(
              :shell_expand_guest_path, opts[:guestpath])

            # Do the actual creating and mounting
            machine.communicate.sudo("mkdir -p #{expanded_guest_path}")

            # Mount
            hostpath = opts[:hostpath].dup
            hostpath.gsub!("'", "'\\\\''")

            # Figure out any options
            mount_opts = ["vers=#{opts[:nfs_version]}", "udp"]
            if opts[:mount_options]
              mount_opts = opts[:mount_options].dup
            end

            mount_command = "mount -o '#{mount_opts.join(",")}' #{ip}:'#{hostpath}' #{expanded_guest_path}"
            retryable(:on => Vagrant::Errors::LinuxNFSMountFailed, :tries => 5, :sleep => 2) do
              machine.communicate.sudo(mount_command,
                                       :error_class => Vagrant::Errors::LinuxNFSMountFailed)
            end
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
tamtam-vagrant-reload-1.1.3 vendor/cache/vagrant-0ac2a8738841/plugins/guests/linux/cap/mount_nfs.rb
tamtam-vagrant-reload-1.1.2 vendor/cache/vagrant-0ac2a8738841/plugins/guests/linux/cap/mount_nfs.rb
tamtam-vagrant-reload-1.1.1 vendor/cache/vagrant-0ac2a8738841/plugins/guests/linux/cap/mount_nfs.rb
tamtam-vagrant-reload-1.1 vendor/cache/vagrant-0ac2a8738841/plugins/guests/linux/cap/mount_nfs.rb
tnargav-1.3.6 plugins/guests/linux/cap/mount_nfs.rb
tnargav-1.3.3 plugins/guests/linux/cap/mount_nfs.rb