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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/vagrant-nfs4j/synced_folder.rb', line 7
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)
config_nfs_versions = {}
config_nfs_udps = {}
folders.each do |id, opts|
config_nfs_versions[id] = opts[:nfs_version]
config_nfs_udps[id] = opts[:nfs_udp]
end
folders.each {|id, opts| prepare_folder(machine, opts)}
folders.each do |id, opts|
opts[:nfs_udp] = config_nfs_udps[id]
opts[:nfs_version] = config_nfs_versions[id]
unless opts[:nfs_version]
opts[:nfs_version] = '4.1'
end
end
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, 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|
opts = opts.dup
real_hostpath = opts[:hostpath]
if Vagrant::Util::Platform.windows?
opts[:hostpath] = VagrantNfs4j::Utils.prefix_alias(machine, opts[:guestpath])
end
opts[:mount_options] = VagrantNfs4j::Utils.apply_mount_options(opts[:mount_options])
machine.ui.detail(I18n.t('vagrant.actions.vm.share_folders.mounting_entry',
guestpath: opts[:guestpath],
hostpath: real_hostpath))
mount_folders[id] = opts
end
host_ip = nfsopts[:nfs_host_ip]
if (!machine.config.nfs4j.host_ip.empty?)
host_ip = machine.config.nfs4j.host_ip
end
machine.guest.capability(
:mount_nfs_folder, host_ip, mount_folders)
end
|