6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/vagrant-winnfsd/synced_folder.rb', line 6
def enable(machine, folders, nfsopts)
raise Vagrant::Errors::NFSNoHostIP unless nfsopts[:nfs_host_ip]
raise Vagrant::Errors::NFSNoGuestIP unless nfsopts[:nfs_machine_ip]
if machine.guest.capability?(:nfs_client_installed)
installed = machine.guest.capability(:nfs_client_installed)
unless installed
can_install = machine.guest.capability?(:nfs_client_install)
raise Vagrant::Errors::NFSClientNotInstalledInGuest unless can_install
machine.ui.info I18n.t("vagrant.actions.vm.nfs.installing")
machine.guest.capability(:nfs_client_install)
end
end
machine_ip = nfsopts[:nfs_machine_ip]
machine_ip = [machine_ip] unless machine_ip.is_a?(Array)
folders.each { |id, opts| prepare_folder(machine, opts) }
export_folders = folders.dup
export_folders.keys.each do |id|
opts = export_folders[id]
if opts.has_key?(:nfs_export) && !opts[:nfs_export]
export_folders.delete(id)
end
end
@@lock.synchronize do
begin
machine.env.lock("nfs-export") do
machine.ui.info I18n.t("vagrant.actions.vm.nfs.exporting")
machine.env.host.capability(
:nfs_export,
machine.ui, machine.id, machine_ip, export_folders)
end
rescue Vagrant::Errors::EnvironmentLockedError
sleep 1
retry
end
end
machine.ui.info I18n.t("vagrant.actions.vm.nfs.mounting")
mount_folders = {}
folders.each do |id, opts|
if Vagrant::Util::Platform.windows?
unless opts[:mount_options]
mount_opts = ["vers=#{opts[:nfs_version]}"]
mount_opts << "udp" if opts[:nfs_udp]
mount_opts << "nolock"
opts[:mount_options] = mount_opts
end
opts[:hostpath] = '/' + opts[:hostpath].gsub(':', '').gsub('\\', '/')
end
mount_folders[id] = opts.dup if opts[:guestpath]
end
machine.guest.capability(
:mount_nfs_folder, nfsopts[:nfs_host_ip], mount_folders)
end
|