Sha256: fd75940c30ed4caadcef7caaaedb3e7b4f809f57cee0bc030edce0764f40e5ae
Contents?: true
Size: 1.32 KB
Versions: 5
Compression:
Stored size: 1.32 KB
Contents
require 'net/ssh' module Ridley # @author Jamie Winsor <jamie@vialstudios.com> class SSH autoload :Response, 'ridley/ssh/response' autoload :ResponseSet, 'ridley/ssh/response_set' autoload :Worker, 'ridley/ssh/worker' class << self # @param [Ridley::Node, Array<Ridley::Node>] nodes # @param [Hash] options def start(nodes, options = {}, &block) runner = new(nodes, options) result = yield runner runner.terminate result end end include Celluloid include Celluloid::Logger attr_reader :nodes attr_reader :options # @param [Ridley::Node, Array<Ridley::Node>] nodes # @param [Hash] options # @see Net::SSH def initialize(nodes, options = {}) @nodes = Array(nodes) @options = options end # @param [String] command # # @return [Array] def run(command) workers = Array.new futures = self.nodes.collect do |node| workers << worker = Worker.new_link(self.options.freeze) worker.future.run(node.public_hostname, command) end ResponseSet.new.tap do |response_set| futures.each do |future| status, response = future.value response_set.add_response(response) end end ensure workers.map(&:terminate) end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
ridley-0.7.0.beta | lib/ridley/ssh.rb |
ridley-0.6.3 | lib/ridley/ssh.rb |
ridley-0.6.2 | lib/ridley/ssh.rb |
ridley-0.6.1 | lib/ridley/ssh.rb |
ridley-0.6.0 | lib/ridley/ssh.rb |