2016-12-01 02:47:08 +00:00
|
|
|
require_relative "../../../synced_folders/unix_mount_helpers"
|
2016-02-04 15:21:07 +00:00
|
|
|
|
|
|
|
module VagrantPlugins
|
2016-02-04 15:27:53 +00:00
|
|
|
module GuestTinyCore
|
2016-02-04 15:21:07 +00:00
|
|
|
module Cap
|
|
|
|
class MountNFS
|
2016-12-01 02:47:08 +00:00
|
|
|
extend SyncedFolder::UnixMountHelpers
|
2016-02-04 15:21:07 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2016-02-04 16:22:28 +00:00
|
|
|
mount_command = "mount.nfs -o '#{mount_opts.join(",")}' #{ip}:'#{hostpath}' #{expanded_guest_path}"
|
2016-06-18 00:56:04 +00:00
|
|
|
retryable(on: Vagrant::Errors::NFSMountFailed, tries: 8, sleep: 3) do
|
2016-02-04 15:21:07 +00:00
|
|
|
machine.communicate.sudo(mount_command,
|
2016-06-18 00:56:04 +00:00
|
|
|
error_class: Vagrant::Errors::NFSMountFailed)
|
2016-02-04 15:21:07 +00:00
|
|
|
end
|
|
|
|
|
2016-12-01 02:47:08 +00:00
|
|
|
emit_upstart_notification(machine, expanded_guest_path)
|
2016-02-04 15:21:07 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|