]> gitweb.fluxo.info Git - leap/leap_cli.git/commitdiff
use RsyncCommand instead of supply drop.
authorelijah <elijah@riseup.net>
Mon, 18 Mar 2013 07:57:04 +0000 (00:57 -0700)
committerelijah <elijah@riseup.net>
Mon, 1 Apr 2013 01:19:23 +0000 (18:19 -0700)
lib/leap_cli/remote/plugin.rb
lib/leap_cli/version.rb

index 38705a9495bcca3fd13dca199934964fac713be5..48248585f0b44991c62f940cb7a304a426729038 100644 (file)
@@ -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)
index 0f494b44a2540ac4b898e15e4dce654d53b2105c..232eb45e5c0fedda15221eb178bdff1c608243d8 100644 (file)
@@ -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