From 5de3f30bb0d3481dea8bc941ab8e36494ddc4d39 Mon Sep 17 00:00:00 2001 From: Chad Maloney Date: Tue, 25 Nov 2014 12:38:41 -0600 Subject: [PATCH 1/5] GH-4201: Added rsync__showoutput to display rsync output to console --- CHANGELOG.md | 2 ++ plugins/synced_folders/rsync/helper.rb | 12 +++++++++++- templates/locales/en.yml | 1 + website/docs/source/v2/synced-folders/rsync.html.md | 4 ++++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53565b085..72a0903d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,8 @@ IMPROVEMENTS: - synced\_folders/nfs: Won't use `sudo` to write to /etc/exports if there are write privileges. [GH-2643] - synced\_folders/smb: Credentials from one SMB will be copied to the rest. [GH-4675] + - synced\_filders/rsync: Added rsync__showoutput option to echo rsync output + to console [GH-4201] BUG FIXES: diff --git a/plugins/synced_folders/rsync/helper.rb b/plugins/synced_folders/rsync/helper.rb index bc7f6d116..21d0890ad 100644 --- a/plugins/synced_folders/rsync/helper.rb +++ b/plugins/synced_folders/rsync/helper.rb @@ -121,13 +121,23 @@ module VagrantPlugins machine.ui.info(I18n.t( "vagrant.rsync_folder_excludes", excludes: excludes.inspect)) end + if opts.include?(:showoutput) + machine.ui.info(I18n.t("vagrant.rsync_showingoutput")); + end # If we have tasks to do before rsyncing, do those. if machine.guest.capability?(:rsync_pre) machine.guest.capability(:rsync_pre, opts) end - r = Vagrant::Util::Subprocess.execute(*(command + [command_opts])) + if opts.include?(:showoutput) + command_opts[:notify] = [ :stdout, :stderr ]; + r = Vagrant::Util::Subprocess.execute( + *(command + [command_opts])) { |io_name,data| machine.ui.info("rsync[#{io_name}] -> #{data}") } + else + r = Vagrant::Util::Subprocess.execute(*(command + [command_opts])) + end + if r.exit_code != 0 raise Vagrant::Errors::RSyncError, command: command.join(" "), diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 81365587d..908e3bfea 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -212,6 +212,7 @@ en: 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_showing_output: "Showing rsync output..." rsync_ssh_password: |- The machine you're rsyncing folders to is configured to use password-based authentication. Vagrant can't script rsync to automatically diff --git a/website/docs/source/v2/synced-folders/rsync.html.md b/website/docs/source/v2/synced-folders/rsync.html.md index 62e88d0dd..d92c6d46c 100644 --- a/website/docs/source/v2/synced-folders/rsync.html.md +++ b/website/docs/source/v2/synced-folders/rsync.html.md @@ -62,6 +62,10 @@ The rsync synced folder type accepts the following options: pattern. By default, the ".vagrant/" directory is excluded. We recommend excluding revision control directories such as ".git/" as well. +* `rsync__showoutput` (boolean) - If true, then the output from the rsync + process will be echoed to the console. The output of rsync is subject + to rsync__args of course. By default, this is false. + ## Example The following is an example of using RSync to sync a folder: From cf784d5d3cdc2c1a49b15fc4dc5a0fcc76a40664 Mon Sep 17 00:00:00 2001 From: Chad Maloney Date: Tue, 25 Nov 2014 14:37:59 -0600 Subject: [PATCH 2/5] GH-4201: Split process output by line so prefix shows on each line. Also fixed localization reference. --- plugins/synced_folders/rsync/helper.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/synced_folders/rsync/helper.rb b/plugins/synced_folders/rsync/helper.rb index 21d0890ad..eb637af96 100644 --- a/plugins/synced_folders/rsync/helper.rb +++ b/plugins/synced_folders/rsync/helper.rb @@ -31,6 +31,10 @@ module VagrantPlugins Regexp.new(regexp) end + # Output rsync process stdout/stderr line by line + def self.outputRsyncData(io_name, data) + end + def self.rsync_single(machine, ssh_info, opts) # Folder info guestpath = opts[:guestpath] @@ -122,7 +126,7 @@ module VagrantPlugins "vagrant.rsync_folder_excludes", excludes: excludes.inspect)) end if opts.include?(:showoutput) - machine.ui.info(I18n.t("vagrant.rsync_showingoutput")); + machine.ui.info(I18n.t("vagrant.rsync_showing_output")); end # If we have tasks to do before rsyncing, do those. @@ -132,8 +136,9 @@ module VagrantPlugins if opts.include?(:showoutput) command_opts[:notify] = [ :stdout, :stderr ]; - r = Vagrant::Util::Subprocess.execute( - *(command + [command_opts])) { |io_name,data| machine.ui.info("rsync[#{io_name}] -> #{data}") } + r = Vagrant::Util::Subprocess.execute(*(command + [command_opts])) { + |io_name,data| data.each_line { |line| machine.ui.info("rsync[#{io_name}] -> #{line}") } + } else r = Vagrant::Util::Subprocess.execute(*(command + [command_opts])) end From fa99f95ea1b77259f8b3956fa4b01c88f76fdaa9 Mon Sep 17 00:00:00 2001 From: Chad Maloney Date: Tue, 25 Nov 2014 14:38:59 -0600 Subject: [PATCH 3/5] GH-4201: Filders isn't a real word --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72a0903d6..8880478e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,7 +40,7 @@ IMPROVEMENTS: - synced\_folders/nfs: Won't use `sudo` to write to /etc/exports if there are write privileges. [GH-2643] - synced\_folders/smb: Credentials from one SMB will be copied to the rest. [GH-4675] - - synced\_filders/rsync: Added rsync__showoutput option to echo rsync output + - synced\_folders/rsync: Added rsync__showoutput option to echo rsync output to console [GH-4201] BUG FIXES: From 1ed31afeba7b919b0ab54a02f0858c45278ce35c Mon Sep 17 00:00:00 2001 From: Chad Maloney Date: Tue, 25 Nov 2014 14:39:56 -0600 Subject: [PATCH 4/5] GH-4201: Cleaned up some leftover junk I missed removing --- plugins/synced_folders/rsync/helper.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/plugins/synced_folders/rsync/helper.rb b/plugins/synced_folders/rsync/helper.rb index eb637af96..a0a8598e6 100644 --- a/plugins/synced_folders/rsync/helper.rb +++ b/plugins/synced_folders/rsync/helper.rb @@ -31,10 +31,6 @@ module VagrantPlugins Regexp.new(regexp) end - # Output rsync process stdout/stderr line by line - def self.outputRsyncData(io_name, data) - end - def self.rsync_single(machine, ssh_info, opts) # Folder info guestpath = opts[:guestpath] From d2e1500c748051ecfd900f2cd3ebbcf7a4a38774 Mon Sep 17 00:00:00 2001 From: Chad Maloney Date: Mon, 5 Jan 2015 14:36:00 -0600 Subject: [PATCH 5/5] Review comments applied. Removed changelog. Changed showoutput to verbose. --- CHANGELOG.md | 2 -- plugins/synced_folders/rsync/helper.rb | 4 ++-- website/docs/source/v2/synced-folders/rsync.html.md | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8880478e9..53565b085 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,8 +40,6 @@ IMPROVEMENTS: - synced\_folders/nfs: Won't use `sudo` to write to /etc/exports if there are write privileges. [GH-2643] - synced\_folders/smb: Credentials from one SMB will be copied to the rest. [GH-4675] - - synced\_folders/rsync: Added rsync__showoutput option to echo rsync output - to console [GH-4201] BUG FIXES: diff --git a/plugins/synced_folders/rsync/helper.rb b/plugins/synced_folders/rsync/helper.rb index a0a8598e6..37a8a1ddd 100644 --- a/plugins/synced_folders/rsync/helper.rb +++ b/plugins/synced_folders/rsync/helper.rb @@ -121,7 +121,7 @@ module VagrantPlugins machine.ui.info(I18n.t( "vagrant.rsync_folder_excludes", excludes: excludes.inspect)) end - if opts.include?(:showoutput) + if opts.include?(:verbose) machine.ui.info(I18n.t("vagrant.rsync_showing_output")); end @@ -130,7 +130,7 @@ module VagrantPlugins machine.guest.capability(:rsync_pre, opts) end - if opts.include?(:showoutput) + if opts.include?(:verbose) command_opts[:notify] = [ :stdout, :stderr ]; r = Vagrant::Util::Subprocess.execute(*(command + [command_opts])) { |io_name,data| data.each_line { |line| machine.ui.info("rsync[#{io_name}] -> #{line}") } diff --git a/website/docs/source/v2/synced-folders/rsync.html.md b/website/docs/source/v2/synced-folders/rsync.html.md index d92c6d46c..3e97be86d 100644 --- a/website/docs/source/v2/synced-folders/rsync.html.md +++ b/website/docs/source/v2/synced-folders/rsync.html.md @@ -62,7 +62,7 @@ The rsync synced folder type accepts the following options: pattern. By default, the ".vagrant/" directory is excluded. We recommend excluding revision control directories such as ".git/" as well. -* `rsync__showoutput` (boolean) - If true, then the output from the rsync +* `rsync__verbose` (boolean) - If true, then the output from the rsync process will be echoed to the console. The output of rsync is subject to rsync__args of course. By default, this is false.