commands/rsync: handle proxy machines [GH-4066]

This commit is contained in:
Mitchell Hashimoto 2014-10-22 16:17:13 -07:00
parent bdd0424d7d
commit 0e29dd5668
6 changed files with 37 additions and 2 deletions

View File

@ -11,6 +11,7 @@ BUG FIXES:
- core: Fix cases where sometimes SSH connection would hang.
- command/docker-logs: Won't crash if container is removed. [GH-3990]
- command/rsync: Sync to Docker containers properly. [GH-4066]
- providers/docker: Create args works. [GH-4526]
- providers/docker: Nicer error if package is called. [GH-4595]
- providers/docker: Host IP restriction is forwarded through. [GH-4505]

View File

@ -93,11 +93,12 @@ module Vagrant
config = opts[:config]
config ||= machine.config.vm
config_folders = config.synced_folders
folders = {}
# Determine all the synced folders as well as the implementation
# they're going to use.
config.synced_folders.each do |id, data|
config_folders.each do |id, data|
# Ignore disabled synced folders
next if data[:disabled]

View File

@ -0,0 +1,12 @@
module VagrantPlugins
module DockerProvider
module Cap
module ProxyMachine
def self.proxy_machine(machine)
return nil if !machine.provider.host_vm?
machine.provider.host_vm
end
end
end
end
end

View File

@ -56,6 +56,11 @@ module VagrantPlugins
Cap::PublicAddress
end
provider_capability("docker", "proxy_machine") do
require_relative "cap/proxy_machine"
Cap::ProxyMachine
end
protected
def self.init!

View File

@ -27,6 +27,18 @@ module VagrantPlugins
# Go through each machine and perform the rsync
error = false
with_target_vms(argv) do |machine|
if machine.provider.capability?(:proxy_machine)
proxy = machine.provider.capability(:proxy_machine)
if proxy
machine.ui.warn(I18n.t(
"vagrant.rsync_proxy_machine",
name: machine.name.to_s,
provider: machine.provider_name.to_s))
machine = proxy
end
end
if !machine.communicate.ready?
machine.ui.error(I18n.t("vagrant.rsync_communicator_not_ready"))
error = true
@ -34,7 +46,7 @@ module VagrantPlugins
end
# Determine the rsync synced folders for this machine
folders = synced_folders(machine)[:rsync]
folders = synced_folders(machine, cached: true)[:rsync]
next if !folders || folders.empty?
# Get the SSH info for this machine so we can access it

View File

@ -195,6 +195,10 @@ en:
Rsyncing folder: %{hostpath} => %{guestpath}
rsync_folder_excludes: " - Exclude: %{excludes}"
rsync_installing: "Installing rsync to the VM..."
rsync_proxy_machine: |-
The provider ('%{provider}') for the machine '%{name}' is
using a proxy machine. RSync will sync to this proxy
instead of directly to the environment itself.
rsync_ssh_password: |-
The machine you're rsyncing folders to is configured to use
password-based authentication. Vagrant can't script rsync to automatically