broke up ssh connection to a target and options, so we can pass options through to rsync (no rsync yet)

This commit is contained in:
Nick Gauthier 2010-02-09 09:56:06 -05:00
parent c743175875
commit 5b53276af6
4 changed files with 15 additions and 13 deletions

View File

@ -11,7 +11,6 @@ begin
gem.homepage = "http://github.com/ngauthier/hydra"
gem.authors = ["Nick Gauthier"]
gem.add_development_dependency "shoulda", "= 2.10.3"
gem.add_dependency "net-ssh", "= 2.0.19"
end
Jeweler::GemcutterTasks.new
rescue LoadError

View File

@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Nick Gauthier"]
s.date = %q{2010-02-06}
s.date = %q{2010-02-09}
s.description = %q{Spread your tests over multiple machines to test your code faster.}
s.email = %q{nick@smartlogicsolutions.com}
s.extra_rdoc_files = [
@ -81,14 +81,11 @@ Gem::Specification.new do |s|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
s.add_development_dependency(%q<shoulda>, ["= 2.10.3"])
s.add_runtime_dependency(%q<net-ssh>, ["= 2.0.19"])
else
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
s.add_dependency(%q<net-ssh>, ["= 2.0.19"])
end
else
s.add_dependency(%q<shoulda>, ["= 2.10.3"])
s.add_dependency(%q<net-ssh>, ["= 2.0.19"])
end
end

View File

@ -94,14 +94,17 @@ module Hydra #:nodoc:
def boot_ssh_worker(worker)
runners = worker.fetch('runners') { raise "You must specify the number of runners" }
connect = worker.fetch('connect') { raise "You must specify SSH connection options" }
connect = worker.fetch('connect') { raise "You must specify an SSH connection target" }
ssh_opts = worker.fetch('ssh_opts') { "" }
directory = worker.fetch('directory') { raise "You must specify a remote directory" }
command = worker.fetch('command') {
"ruby -e \"require 'rubygems'; require 'hydra'; Hydra::Worker.new(:io => Hydra::Stdio.new, :runners => #{runners}, :verbose => #{@verbose});\""
}
trace "Synchronizing with #{connect} [NOT REALLY]"
trace "Booting SSH worker"
ssh = Hydra::SSH.new(connect, directory, command)
ssh = Hydra::SSH.new("#{ssh_opts} #{connect}", directory, command)
return { :io => ssh, :idle => false, :type => :ssh }
end

View File

@ -17,18 +17,21 @@ module Hydra #:nodoc:
include Open3
include Hydra::MessagingIO
# Initialize new SSH connection. The single parameters is passed
# directly to ssh for starting a connection. So you can do:
# Hydra::SSH.new('localhost')
# Hydra::SSH.new('user@server.com')
# Hydra::SSH.new('-p 3022 user@server.com')
# etc..
# Initialize new SSH connection.
# The first parameter is passed directly to ssh for starting a connection.
# The second parameter is the directory to CD into once connected.
# The third parameter is the command to run
# So you can do:
# Hydra::SSH.new('-p 3022 user@server.com', '/home/user/Desktop', 'ls -l')
# To connect to server.com as user on port 3022, then CD to their desktop, then
# list all the files.
def initialize(connection_options, directory, command)
@writer, @reader, @error = popen3("ssh -tt #{connection_options}")
@writer.write("cd #{directory}\n")
@writer.write(command+"\n")
end
# Close the SSH connection
def close
@writer.write "exit\n"
super