Merge pull request #10326 from briancain/add-automount-vbox
Fixes #10016: Add `automount` flag if specified with synced_folder
This commit is contained in:
commit
238a46299b
|
@ -674,6 +674,8 @@ module VagrantPlugins
|
||||||
hostpath]
|
hostpath]
|
||||||
args << "--transient" if folder.key?(:transient) && folder[:transient]
|
args << "--transient" if folder.key?(:transient) && folder[:transient]
|
||||||
|
|
||||||
|
args << "--automount" if folder.key?(:automount) && folder[:automount]
|
||||||
|
|
||||||
if folder[:SharedFoldersEnableSymlinksCreate]
|
if folder[:SharedFoldersEnableSymlinksCreate]
|
||||||
# Enable symlinks on the shared folder
|
# Enable symlinks on the shared folder
|
||||||
execute("setextradata", @uuid, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/#{folder[:name]}", "1", retryable: true)
|
execute("setextradata", @uuid, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/#{folder[:name]}", "1", retryable: true)
|
||||||
|
|
|
@ -124,7 +124,8 @@ module VagrantPlugins
|
||||||
name: os_friendly_id(id),
|
name: os_friendly_id(id),
|
||||||
hostpath: hostpath.to_s,
|
hostpath: hostpath.to_s,
|
||||||
transient: transient,
|
transient: transient,
|
||||||
SharedFoldersEnableSymlinksCreate: enable_symlink_create
|
SharedFoldersEnableSymlinksCreate: enable_symlink_create,
|
||||||
|
automount: !!data[:automount]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,6 +15,12 @@ describe VagrantPlugins::ProviderVirtualBox::Driver::Version_5_0 do
|
||||||
:transient=>false,
|
:transient=>false,
|
||||||
:SharedFoldersEnableSymlinksCreate=>true}]}
|
:SharedFoldersEnableSymlinksCreate=>true}]}
|
||||||
|
|
||||||
|
let(:folders_automount) { [{:name=>"folder",
|
||||||
|
:hostpath=>"/Users/brian/vagrant-folder",
|
||||||
|
:transient=>false,
|
||||||
|
:automount=>true,
|
||||||
|
:SharedFoldersEnableSymlinksCreate=>true}]}
|
||||||
|
|
||||||
let(:folders_disabled) { [{:name=>"folder",
|
let(:folders_disabled) { [{:name=>"folder",
|
||||||
:hostpath=>"/Users/brian/vagrant-folder",
|
:hostpath=>"/Users/brian/vagrant-folder",
|
||||||
:transient=>false,
|
:transient=>false,
|
||||||
|
@ -32,6 +38,19 @@ describe VagrantPlugins::ProviderVirtualBox::Driver::Version_5_0 do
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "enables automount if option is true" do
|
||||||
|
expect(subprocess).to receive(:execute).
|
||||||
|
with("VBoxManage", "setextradata", anything, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/folder", "1", {:notify=>[:stdout, :stderr]}).
|
||||||
|
and_return(subprocess_result(exit_code: 0))
|
||||||
|
|
||||||
|
expect(subprocess).to receive(:execute).
|
||||||
|
with("VBoxManage", "sharedfolder", "add", anything, "--name", "folder", "--hostpath", "/Users/brian/vagrant-folder", "--automount", {:notify=>[:stdout, :stderr]}).
|
||||||
|
and_return(subprocess_result(exit_code: 0))
|
||||||
|
subject.share_folders(folders_automount)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
it "disables SharedFoldersEnableSymlinksCreate if false" do
|
it "disables SharedFoldersEnableSymlinksCreate if false" do
|
||||||
expect(subprocess).to receive(:execute).
|
expect(subprocess).to receive(:execute).
|
||||||
with("VBoxManage", "sharedfolder", "add", anything, "--name", "folder", "--hostpath", "/Users/brian/vagrant-folder", {:notify=>[:stdout, :stderr]}).
|
with("VBoxManage", "sharedfolder", "add", anything, "--name", "folder", "--hostpath", "/Users/brian/vagrant-folder", {:notify=>[:stdout, :stderr]}).
|
||||||
|
|
|
@ -43,6 +43,7 @@ describe VagrantPlugins::ProviderVirtualBox::SyncedFolder do
|
||||||
{:SharedFoldersEnableSymlinksCreate=>true,
|
{:SharedFoldersEnableSymlinksCreate=>true,
|
||||||
:guestpath=>"/folder",
|
:guestpath=>"/folder",
|
||||||
:hostpath=>"/Users/brian/vagrant-folder",
|
:hostpath=>"/Users/brian/vagrant-folder",
|
||||||
|
:automount=>false,
|
||||||
:disabled=>false,
|
:disabled=>false,
|
||||||
:__vagrantfile=>true}} }
|
:__vagrantfile=>true}} }
|
||||||
|
|
||||||
|
@ -50,12 +51,23 @@ describe VagrantPlugins::ProviderVirtualBox::SyncedFolder do
|
||||||
{:SharedFoldersEnableSymlinksCreate=>false,
|
{:SharedFoldersEnableSymlinksCreate=>false,
|
||||||
:guestpath=>"/folder",
|
:guestpath=>"/folder",
|
||||||
:hostpath=>"/Users/brian/vagrant-folder",
|
:hostpath=>"/Users/brian/vagrant-folder",
|
||||||
|
:automount=>false,
|
||||||
:disabled=>false,
|
:disabled=>false,
|
||||||
:__vagrantfile=>true}} }
|
:__vagrantfile=>true}} }
|
||||||
|
|
||||||
|
|
||||||
|
let(:folders_automount) { {"/folder"=>
|
||||||
|
{:SharedFoldersEnableSymlinksCreate=>true,
|
||||||
|
:guestpath=>"/folder",
|
||||||
|
:hostpath=>"/Users/brian/vagrant-folder",
|
||||||
|
:disabled=>false,
|
||||||
|
:automount=>true,
|
||||||
|
:__vagrantfile=>true}} }
|
||||||
|
|
||||||
let(:folders_nosymvar) { {"/folder"=>
|
let(:folders_nosymvar) { {"/folder"=>
|
||||||
{:guestpath=>"/folder",
|
{:guestpath=>"/folder",
|
||||||
:hostpath=>"/Users/brian/vagrant-folder",
|
:hostpath=>"/Users/brian/vagrant-folder",
|
||||||
|
:automount=>false,
|
||||||
:disabled=>false,
|
:disabled=>false,
|
||||||
:__vagrantfile=>true}} }
|
:__vagrantfile=>true}} }
|
||||||
|
|
||||||
|
@ -66,28 +78,33 @@ describe VagrantPlugins::ProviderVirtualBox::SyncedFolder do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should prepare and share the folders" do
|
it "should prepare and share the folders" do
|
||||||
expect(driver).to receive(:share_folders).with([{:name=>"folder", :hostpath=>"/Users/brian/vagrant-folder", :transient=>false, :SharedFoldersEnableSymlinksCreate=>true}])
|
expect(driver).to receive(:share_folders).with([{:name=>"folder", :hostpath=>"/Users/brian/vagrant-folder", :transient=>false, :automount=>false, :SharedFoldersEnableSymlinksCreate=>true}])
|
||||||
subject.prepare(machine, folders, nil)
|
subject.prepare(machine, folders, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should prepare and share the folders without symlinks enabled" do
|
it "should prepare and share the folders without symlinks enabled" do
|
||||||
expect(driver).to receive(:share_folders).with([{:name=>"folder", :hostpath=>"/Users/brian/vagrant-folder", :transient=>false, :SharedFoldersEnableSymlinksCreate=>false}])
|
expect(driver).to receive(:share_folders).with([{:name=>"folder", :hostpath=>"/Users/brian/vagrant-folder", :transient=>false, :automount=>false, :SharedFoldersEnableSymlinksCreate=>false}])
|
||||||
subject.prepare(machine, folders_disabled, nil)
|
subject.prepare(machine, folders_disabled, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should prepare and share the folders without symlinks enabled with env var set" do
|
it "should prepare and share the folders without symlinks enabled with env var set" do
|
||||||
stub_env('VAGRANT_DISABLE_VBOXSYMLINKCREATE'=>'1')
|
stub_env('VAGRANT_DISABLE_VBOXSYMLINKCREATE'=>'1')
|
||||||
|
|
||||||
expect(driver).to receive(:share_folders).with([{:name=>"folder", :hostpath=>"/Users/brian/vagrant-folder", :transient=>false, :SharedFoldersEnableSymlinksCreate=>false}])
|
expect(driver).to receive(:share_folders).with([{:name=>"folder", :hostpath=>"/Users/brian/vagrant-folder", :transient=>false, :automount=>false, :SharedFoldersEnableSymlinksCreate=>false}])
|
||||||
subject.prepare(machine, folders_nosymvar, nil)
|
subject.prepare(machine, folders_nosymvar, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should prepare and share the folders and override symlink setting" do
|
it "should prepare and share the folders and override symlink setting" do
|
||||||
stub_env('VAGRANT_DISABLE_VBOXSYMLINKCREATE'=>'1')
|
stub_env('VAGRANT_DISABLE_VBOXSYMLINKCREATE'=>'1')
|
||||||
|
|
||||||
expect(driver).to receive(:share_folders).with([{:name=>"folder", :hostpath=>"/Users/brian/vagrant-folder", :transient=>false, :SharedFoldersEnableSymlinksCreate=>true}])
|
expect(driver).to receive(:share_folders).with([{:name=>"folder", :hostpath=>"/Users/brian/vagrant-folder", :transient=>false, :automount=>false, :SharedFoldersEnableSymlinksCreate=>true}])
|
||||||
subject.prepare(machine, folders, nil)
|
subject.prepare(machine, folders, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should prepare and share the folders with automount enabled" do
|
||||||
|
expect(driver).to receive(:share_folders).with([{:name=>"folder", :hostpath=>"/Users/brian/vagrant-folder", :transient=>false, :SharedFoldersEnableSymlinksCreate=>true, :automount=>true}])
|
||||||
|
subject.prepare(machine, folders_automount, nil)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#os_friendly_id" do
|
describe "#os_friendly_id" do
|
||||||
|
|
|
@ -18,6 +18,10 @@ the guest to the host and vice versa.
|
||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
|
* `automount` (boolean) - If true, the `--automount` flag will be used when
|
||||||
|
using the VirtualBox tools to share the folder with the guest vm. Defaults to false
|
||||||
|
if not present.
|
||||||
|
|
||||||
* `SharedFoldersEnableSymlinksCreate` (boolean) - If false, will disable the
|
* `SharedFoldersEnableSymlinksCreate` (boolean) - If false, will disable the
|
||||||
ability to create symlinks with the given virtualbox shared folder. Defaults to
|
ability to create symlinks with the given virtualbox shared folder. Defaults to
|
||||||
true if the option is not present.
|
true if the option is not present.
|
||||||
|
|
Loading…
Reference in New Issue