Merge pull request #7425 from tjuerge/6220-mount_shared_folder-via-ssh
Add support for mounting synched folders on windows guest via ssh
This commit is contained in:
commit
21e195c75a
|
@ -1,4 +1,5 @@
|
|||
require "vagrant/util/template_renderer"
|
||||
require "base64"
|
||||
|
||||
module VagrantPlugins
|
||||
module GuestWindows
|
||||
|
@ -33,7 +34,18 @@ module VagrantPlugins
|
|||
vm_provider_unc_path: vm_provider_unc_base + name,
|
||||
})
|
||||
|
||||
if machine.config.vm.communicator == :winrm
|
||||
machine.communicate.execute(script, shell: :powershell)
|
||||
else
|
||||
# Convert script to double byte unicode string then base64 encode
|
||||
# just like PowerShell -EncodedCommand expects.
|
||||
# Suppress the progress stream from leaking to stderr.
|
||||
wrapped_encoded_command = Base64.strict_encode64(
|
||||
"$ProgressPreference='SilentlyContinue'; #{script}; exit $LASTEXITCODE".encode('UTF-16LE', 'UTF-8'))
|
||||
# Execute encoded PowerShell script via OpenSSH shell
|
||||
machine.communicate.execute("powershell.exe -noprofile -executionpolicy bypass " +
|
||||
"-encodedcommand '#{wrapped_encoded_command}'", shell: "sh")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,10 +6,15 @@ describe "VagrantPlugins::GuestWindows::Cap::MountSharedFolder" do
|
|||
|
||||
let(:machine) { double("machine") }
|
||||
let(:communicator) { double(:execute) }
|
||||
let(:config) { double("config") }
|
||||
let(:vm) { double("vm") }
|
||||
|
||||
before do
|
||||
allow(machine).to receive(:communicate).and_return(communicator)
|
||||
allow(communicator).to receive(:execute)
|
||||
allow(machine).to receive(:config).and_return(config)
|
||||
allow(config).to receive(:vm).and_return(vm)
|
||||
allow(vm).to receive(:communicator).and_return(:winrm)
|
||||
end
|
||||
|
||||
describe "virtualbox" do
|
||||
|
@ -98,4 +103,22 @@ describe "VagrantPlugins::GuestWindows::Cap::MountSharedFolder" do
|
|||
end
|
||||
end
|
||||
|
||||
describe "virtualbox-ssh" do
|
||||
|
||||
let(:described_class) do
|
||||
VagrantPlugins::GuestWindows::Plugin.components.guest_capabilities[:windows].get(:mount_virtualbox_shared_folder)
|
||||
end
|
||||
|
||||
before do
|
||||
allow(vm).to receive(:communicator).and_return(:ssh)
|
||||
end
|
||||
|
||||
describe ".mount_shared_folder" do
|
||||
it "should call mount_volume script via ssh" do
|
||||
expect(communicator).to receive(:execute).with(/powershell/, shell: "sh")
|
||||
described_class.mount_virtualbox_shared_folder(machine, 'name', 'guestpath', {})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue