Sha256: f0ee7449c4b3b550568b8343c9d8e1a491f2634cec3d7a3a309284d346e78db9
Contents?: true
Size: 1.41 KB
Versions: 3
Compression:
Stored size: 1.41 KB
Contents
require 'net/ssh' module Ridley module HostConnector # @author Jamie Winsor <reset@riotgames.com> class SSH require_relative 'ssh/worker' class << self # @param [Ridley::NodeObject, Array<Ridley::NodeObject>] nodes # @param [Hash] options def start(nodes, options = {}, &block) runner = new(nodes, options) result = yield runner runner.terminate result ensure runner.terminate if runner && runner.alive? end end include Celluloid include Celluloid::Logger attr_reader :nodes attr_reader :options # @param [Ridley::NodeObject, Array<Ridley::NodeObject>] 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(node.public_hostname, self.options.freeze) worker.future.run(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 end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ridley-0.12.4 | lib/ridley/host_connector/ssh.rb |
ridley-0.12.3 | lib/ridley/host_connector/ssh.rb |
ridley-0.12.2 | lib/ridley/host_connector/ssh.rb |