class Rubble::Executor::Remote
Attributes
box[R]
local_executor[R]
server[R]
Public Class Methods
new(server, local_executor)
click to toggle source
Calls superclass method
Rubble::Executor::Base::new
# File lib/rubble/executor/remote.rb, line 13 def initialize(server, local_executor) super() @server = server @local_executor = local_executor @box = Rye::Box.new(server.name, :safe => false) end
Public Instance Methods
cd(directory, create)
click to toggle source
# File lib/rubble/executor/remote.rb, line 34 def cd(directory, create) @log.info("Changing directory to #{directory}.") if create then mkdir directory end box.cd(directory.to_s) end
close()
click to toggle source
# File lib/rubble/executor/remote.rb, line 55 def close if not @box.nil? then @box.disconnect end end
file_exists?(file_name)
click to toggle source
# File lib/rubble/executor/remote.rb, line 25 def file_exists?(file_name) box.file_exists?(file_name) end
mkdir(directory)
click to toggle source
# File lib/rubble/executor/remote.rb, line 29 def mkdir(directory) @log.info("Creating directory '#{directory}'.") exec('mkdir', '-p', directory.to_s) end
rsync_remote_prefix()
click to toggle source
# File lib/rubble/executor/remote.rb, line 21 def rsync_remote_prefix "#{server.name}:" end
run(*command)
click to toggle source
# File lib/rubble/executor/remote.rb, line 47 def run(*command) Logging.context(:server => server.name) do command_str = Shellwords.join(command) @log.debug(command_str) box.execute(command_str) end end
symlink(source, target)
click to toggle source
# File lib/rubble/executor/remote.rb, line 42 def symlink(source, target) @log.info("Symlinking #{source} to #{target}.") run('ln', '-s', '-f', '-T', source.to_s, target.to_s) end
sync_down(filesets, target_dir, *options)
click to toggle source
# File lib/rubble/executor/remote.rb, line 68 def sync_down(filesets, target_dir, *options) files = rsync_includes(filesets).map {|f| rsync_remote_prefix + f} parameters = [target_dir].concat(files) parameters.concat(options) @local_executor.rsync *parameters end
sync_remote(source_dir, target_dir, *options)
click to toggle source
# File lib/rubble/executor/remote.rb, line 75 def sync_remote(source_dir, target_dir, *options) parameters = [source_dir, target_dir, *options] rsync *parameters end
sync_up(filesets, target_dir, *options)
click to toggle source
# File lib/rubble/executor/remote.rb, line 61 def sync_up(filesets, target_dir, *options) includes = rsync_includes(filesets) parameters = includes.dirs.dup << (rsync_remote_prefix + target_dir).to_s @local_executor.rsync(*parameters, :includes => includes.files, :recursive => true, :delete => true, :delete_excluded => true) end