27 lines
935 B
Ruby
27 lines
935 B
Ruby
|
module VagrantPlugins
|
||
|
module GuestLinux
|
||
|
module Cap
|
||
|
class MountNFS
|
||
|
def self.mount_nfs(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
|
||
|
mount_command = "mount -o vers=#{opts[:nfs_version]} #{ip}:'#{opts[: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
|