diff options
author | Jamis Buck <jamis@37signals.com> | 2005-08-06 19:35:25 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2005-08-06 19:35:25 +0000 |
commit | 5e558bcbf09058d1532db05350c3949333839f16 (patch) | |
tree | 2afbd469b29b924ff009f267f5036f3d08fc1080 /switchtower/lib | |
parent | 25ce9f3bc95dc8aceb8bd51dd3786ae9e0fdfa17 (diff) | |
download | rails-5e558bcbf09058d1532db05350c3949333839f16.tar.gz rails-5e558bcbf09058d1532db05350c3949333839f16.tar.bz2 rails-5e558bcbf09058d1532db05350c3949333839f16.zip |
When executing multiline commands, escape newlines with a backslash
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1975 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'switchtower/lib')
-rw-r--r-- | switchtower/lib/switchtower/actor.rb | 38 | ||||
-rw-r--r-- | switchtower/lib/switchtower/command.rb | 2 |
2 files changed, 24 insertions, 16 deletions
diff --git a/switchtower/lib/switchtower/actor.rb b/switchtower/lib/switchtower/actor.rb index cbaf8463e1..db25ca99c2 100644 --- a/switchtower/lib/switchtower/actor.rb +++ b/switchtower/lib/switchtower/actor.rb @@ -12,6 +12,27 @@ module SwitchTower # new actor via Configuration#actor. class Actor + # An adaptor for making the Net::SSH interface look and act like that of the + # Gateway class. + class DefaultConnectionFactory #:nodoc: + def initialize(config) + @config= config + end + + def connect_to(server) + Net::SSH.start(server, :username => @config.user, + :password => @config.password) + end + end + + class <<self + attr_accessor :connection_factory + attr_accessor :command_factory + end + + self.connection_factory = DefaultConnectionFactory + self.command_factory = Command + # The configuration instance associated with this actor. attr_reader :configuration @@ -37,19 +58,6 @@ module SwitchTower # A struct for representing a single instance of an invoked task. TaskCallFrame = Struct.new(:name, :rollback) - # An adaptor for making the Net::SSH interface look and act like that of the - # Gateway class. - class DefaultConnectionFactory #:nodoc: - def initialize(config) - @config= config - end - - def connect_to(server) - Net::SSH.start(server, :username => @config.user, - :password => @config.password) - end - end - # Represents the definition of a single task. class Task #:nodoc: attr_reader :name, :options @@ -88,7 +96,7 @@ module SwitchTower @tasks = {} @task_call_frames = [] @sessions = {} - @factory = DefaultConnectionFactory.new(configuration) + @factory = self.class.connection_factory.new(configuration) end # Define a new task for this actor. The block will be invoked when this @@ -134,7 +142,7 @@ module SwitchTower establish_connections(servers) # execute the command on each server in parallel - command = Command.new(servers, cmd, block, options, self) + command = self.class.command_factory.new(servers, cmd, block, options, self) command.process! # raises an exception if command fails on any server end end diff --git a/switchtower/lib/switchtower/command.rb b/switchtower/lib/switchtower/command.rb index 910c97cb45..807958fd76 100644 --- a/switchtower/lib/switchtower/command.rb +++ b/switchtower/lib/switchtower/command.rb @@ -7,7 +7,7 @@ module SwitchTower def initialize(servers, command, callback, options, actor) #:nodoc: @servers = servers - @command = command + @command = command.gsub(/\r?\n/, "\\\n") @callback = callback @options = options @actor = actor |