2013-04-04 06:46:39 +00:00
|
|
|
require "vagrant/util/retryable"
|
|
|
|
|
2013-04-04 06:33:20 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module GuestLinux
|
|
|
|
module Cap
|
|
|
|
class MountNFS
|
2013-04-04 06:46:39 +00:00
|
|
|
extend Vagrant::Util::Retryable
|
|
|
|
|
|
|
|
def self.mount_nfs_folder(machine, ip, folders)
|
2013-04-04 06:33:20 +00:00
|
|
|
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
|
2013-07-16 23:23:33 +00:00
|
|
|
hostpath = opts[:hostpath].dup
|
|
|
|
hostpath.gsub!("'", "'\\\\''")
|
2013-07-23 20:19:53 +00:00
|
|
|
mount_command = "mount -o udp,vers=#{opts[:nfs_version]} #{ip}:'#{hostpath}' #{expanded_guest_path}"
|
2013-04-04 06:33:20 +00:00
|
|
|
|
|
|
|
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
|