aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/leap_cli/remote/plugin.rb42
-rw-r--r--lib/leap_cli/version.rb2
2 files changed, 15 insertions, 29 deletions
diff --git a/lib/leap_cli/remote/plugin.rb b/lib/leap_cli/remote/plugin.rb
index 38705a9..4824858 100644
--- a/lib/leap_cli/remote/plugin.rb
+++ b/lib/leap_cli/remote/plugin.rb
@@ -2,6 +2,8 @@
# these methods are made available in capistrano tasks as 'leap.method_name'
#
+require 'rsync_command'
+
module LeapCli; module Remote; module Plugin
def required_packages
@@ -53,38 +55,22 @@ module LeapCli; module Remote; module Plugin
# {:source => '', :dest => '', :flags => '', :includes => [], :excludes => []}
#
def rsync_update
- SupplyDrop::Util.thread_pool_size = puppet_parallel_rsync_pool_size
- servers = SupplyDrop::Util.optionally_async(find_servers, puppet_parallel_rsync)
-
- # rsync to each server
- failed_servers = []
- servers.each do |server|
+ rsync = RsyncCommand.new(:logger => logger, :flags => '-a')
+ rsync.asynchronously(find_servers) do |server|
options = yield server
next unless options
-
- # build rsync command
remote_user = server.user || fetch(:user, ENV['USER'])
- rsync_options = {
- :flags => options[:flags],
- :includes => options[:includes],
- :excludes => options[:excludes],
- :ssh => ssh_options.merge(server.options[:ssh_options]||{})
- }
- rsync_cmd = SupplyDrop::Rsync.command(
- options[:source],
- SupplyDrop::Rsync.remote_address(remote_user, server.host, options[:dest]),
- rsync_options
- )
-
- # run command
- chdir = options[:chdir] || Path.provider
- rsync_cmd = "cd #{chdir}; #{rsync_cmd}"
- logger.debug rsync_cmd
- ok = system(rsync_cmd)
- failed_servers << server.host unless ok
+ src = options[:source]
+ dest = {:user => remote_user, :host => server.host, :path => options[:dest]}
+ options[:ssh] = ssh_options.merge(server.options[:ssh_options]||{})
+ options[:chdir] ||= Path.provider
+ rsync.exec(src, dest, options)
+ end
+ if rsync.failed?
+ LeapCli::Util.bail! do
+ LeapCli::Util.log :failed, "to rsync to #{rsync.failures.map{|f|f[:dest][:host]}.join(' ')}"
+ end
end
-
- raise "rsync failed on #{failed_servers.join(',')}" if failed_servers.any?
end
#def logrun(cmd)
diff --git a/lib/leap_cli/version.rb b/lib/leap_cli/version.rb
index 0f494b4..232eb45 100644
--- a/lib/leap_cli/version.rb
+++ b/lib/leap_cli/version.rb
@@ -3,6 +3,6 @@ module LeapCli
VERSION = '0.2.0'
SUMMARY = 'Command line interface to the LEAP platform'
DESCRIPTION = 'The command "leap" can be used to manage a bevy of servers running the LEAP platform from the comfort of your own home.'
- LOAD_PATHS = ['lib', 'vendor/supply_drop/lib', 'vendor/certificate_authority/lib']
+ LOAD_PATHS = ['lib', 'vendor/supply_drop/lib', 'vendor/certificate_authority/lib', 'vendor/rsync_command/lib']
end
end