aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-03-18 00:57:04 -0700
committerelijah <elijah@riseup.net>2013-03-31 18:19:23 -0700
commit52cf8bf4741d3ad42ec86d0128d7bda8c46fd6a3 (patch)
tree14bb3bc0ecf2f3031d7354137c8eeda4f3726fa4
parent60add619ac1dab6518baa7952e3292dcb65625e4 (diff)
downloadleap_cli-52cf8bf4741d3ad42ec86d0128d7bda8c46fd6a3.tar.gz
leap_cli-52cf8bf4741d3ad42ec86d0128d7bda8c46fd6a3.tar.bz2
use RsyncCommand instead of supply drop.
-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