move mountpoint creation to lxc template for lvm rootfs support

This commit is contained in:
Cam Cope 2015-04-05 17:46:22 -07:00
parent c9cd671a32
commit caa3c53a8f
2 changed files with 7 additions and 23 deletions

View file

@ -87,26 +87,14 @@ module Vagrant
def share_folders(folders) def share_folders(folders)
folders.each do |f| folders.each do |f|
share_folder(f[:hostpath], f[:guestpath], f.fetch(:mount_options, 'bind')) share_folder(f[:hostpath], f[:guestpath], f.fetch(:mount_options, nil))
end end
end end
def share_folder(host_path, guest_path, mount_options = nil) def share_folder(host_path, guest_path, mount_options = nil)
guest_path = guest_path.gsub(/^\//, '') guest_path = guest_path.gsub(/^\//, '').gsub(' ', '\\\040')
guest_full_path = rootfs_path.join(guest_path) mount_options = Array(mount_options || ['bind', 'create=dir'])
unless guest_full_path.directory?
begin
@logger.debug("Guest path doesn't exist, creating: #{guest_full_path}")
@sudo_wrapper.run('mkdir', '-p', guest_full_path.to_s)
rescue Errno::EACCES
raise Vagrant::Errors::SharedFolderCreateFailed, :path => guest_path.to_s
end
end
mount_options = Array(mount_options || ['bind'])
host_path = host_path.to_s.gsub(' ', '\\\040') host_path = host_path.to_s.gsub(' ', '\\\040')
guest_path = guest_path.gsub(' ', '\\\040')
@customizations << ['mount.entry', "#{host_path} #{guest_path} none #{mount_options.join(',')} 0 0"] @customizations << ['mount.entry', "#{host_path} #{guest_path} none #{mount_options.join(',')} 0 0"]
end end

View file

@ -192,14 +192,10 @@ describe Vagrant::LXC::Driver do
subject.share_folders(folders) subject.share_folders(folders)
end end
it "creates guest folder under container's rootfs" do
expect(sudo_wrapper).to have_received(:run).with("mkdir", "-p", "#{rootfs_path}/#{expected_guest_path}")
end
it 'adds a mount.entry to its local customizations' do it 'adds a mount.entry to its local customizations' do
expect(subject.customizations).to include [ expect(subject.customizations).to include [
'mount.entry', 'mount.entry',
"#{shared_folder[:hostpath]} #{expected_guest_path} none bind 0 0" "#{shared_folder[:hostpath]} #{expected_guest_path} none bind,create=dir 0 0"
] ]
end end
@ -213,7 +209,7 @@ describe Vagrant::LXC::Driver do
it 'supports directories with spaces' do it 'supports directories with spaces' do
expect(subject.customizations).to include [ expect(subject.customizations).to include [
'mount.entry', 'mount.entry',
"/path/with\\040space tmp/with\\040space none bind 0 0" "/path/with\\040space tmp/with\\040space none bind,create=dir 0 0"
] ]
end end
end end
@ -243,7 +239,7 @@ describe Vagrant::LXC::Driver do
it 'adds a mount.entry to its local customizations' do it 'adds a mount.entry to its local customizations' do
expect(subject.customizations).to include [ expect(subject.customizations).to include [
'mount.entry', 'mount.entry',
"#{shared_folder[:hostpath]} #{expected_guest_path} none bind 0 0" "#{shared_folder[:hostpath]} #{expected_guest_path} none bind,create=dir 0 0"
] ]
end end
end end
@ -273,7 +269,7 @@ describe Vagrant::LXC::Driver do
it 'adds a mount.entry to its local customizations' do it 'adds a mount.entry to its local customizations' do
expect(subject.customizations).to include [ expect(subject.customizations).to include [
'mount.entry', 'mount.entry',
"#{shared_folder[:hostpath]} #{expected_guest_path} none bind 0 0" "#{shared_folder[:hostpath]} #{expected_guest_path} none bind,create=dir 0 0"
] ]
end end
end end