2013-08-06 00:39:44 +00:00
|
|
|
require "vagrant/util/retryable"
|
|
|
|
|
2013-07-11 01:21:06 +00:00
|
|
|
module VagrantPlugins
|
2013-08-06 01:07:45 +00:00
|
|
|
module GuestDarwin
|
|
|
|
module Cap
|
|
|
|
class MountNFSFolder
|
|
|
|
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])
|
2013-08-06 00:39:44 +00:00
|
|
|
|
2014-05-17 19:24:24 +00:00
|
|
|
# Create the folder
|
|
|
|
machine.communicate.sudo("mkdir -p #{expanded_guest_path}")
|
2013-08-06 00:39:44 +00:00
|
|
|
|
2014-05-17 19:24:24 +00:00
|
|
|
# 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 -t nfs " +
|
|
|
|
"-o '#{mount_opts.join(",")}' " +
|
|
|
|
"'#{ip}:#{opts[:hostpath]}' '#{expanded_guest_path}'"
|
2014-05-22 16:35:12 +00:00
|
|
|
retryable(on: Vagrant::Errors::DarwinNFSMountFailed, tries: 10, sleep: 5) do
|
2014-05-17 19:24:24 +00:00
|
|
|
machine.communicate.sudo(
|
|
|
|
mount_command,
|
|
|
|
error_class: Vagrant::Errors::DarwinNFSMountFailed)
|
|
|
|
end
|
2013-08-06 01:07:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-07-11 01:21:06 +00:00
|
|
|
end
|