Sha256: c41b249a7f1420b4d6d5a73e5cf9b3fd6624457bf24abecf177942916a98feef

Contents?: true

Size: 1.56 KB

Versions: 5

Compression:

Stored size: 1.56 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]}"]
            mount_opts << "udp" if opts[:nfs_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: 8, sleep: 3) do
              machine.communicate.sudo(mount_command,
                                       error_class: Vagrant::Errors::LinuxNFSMountFailed)
            end

            # Emit an upstart event if we can
            if machine.communicate.test("test -x /sbin/initctl")
              machine.communicate.sudo(
                "/sbin/initctl emit --no-wait vagrant-mounted MOUNTPOINT=#{expanded_guest_path}")
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 2 versions & 2 rubygems

Version Path
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-1cf2a8db4ccb/plugins/guests/linux/cap/mount_nfs.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-272fb27e0536/plugins/guests/linux/cap/mount_nfs.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-309e896975d1/plugins/guests/linux/cap/mount_nfs.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-b421af58e8b3/plugins/guests/linux/cap/mount_nfs.rb
vagrant-tiktalik-0.0.3 vendor/bundle/ruby/2.0.0/bundler/gems/vagrant-1e28f1ac31e7/plugins/guests/linux/cap/mount_nfs.rb