Sha256: f19cbdbaf80f83efba2a973213106ff7e423ef14bbb75dd2b29e707a9d2f255c

Contents?: true

Size: 1.23 KB

Versions: 18

Compression:

Stored size: 1.23 KB

Contents

module Phase
  module SSH
    class BastionCoordinator

      def initialize(bastion, destination_hosts)
        @bastion = bastion
        @destination_hosts = destination_hosts
      end

      def each(options = {}, &block)
        if hosts
          queue = Queue.new
          @destination_hosts.each {|host| queue << hosts }

          options = default_options.merge(options)
          options[:address_queue] = queue

          case options[:in]
          when :parallel then ::Phase::SSH::Runners::Parallel
          when :sequence then ::Phase::SSH::Runners::Sequential
          when :groups   then ::Phase::SSH::Runners::Group
          else
            raise RuntimeError, "Don't know how to handle run style #{options[:in].inspect}"
          end.new([@bastion] * @destination_hosts.count, options, &block).execute
        else
          Runners::Null.new(hosts, options, &block).execute
        end
      end

      # def run!(options = {}, &block)
      #   backend = Backend.new(@bastion, options)
      #
      #   results = @destination_hosts.each do |host|
      #     backend.run do
      #       on_remote_host(ip) { instance_exec(&block) }
      #     end
      #   end
      #
      #   results.flatten
      # end

    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
phase-1.0.2 lib/phase/kit/ssh/bastion_coordinator.rb
phase-1.0.1 lib/phase/kit/ssh/bastion_coordinator.rb
phase-1.0.0 lib/phase/kit/ssh/bastion_coordinator.rb
phase-1.0.0.rc2 lib/phase/kit/ssh/bastion_coordinator.rb
phase-1.0.0.rc1 lib/phase/kit/ssh/bastion_coordinator.rb
phase-0.0.17 lib/phase/kit/ssh/bastion_coordinator.rb
phase-0.0.16.1 lib/phase/kit/ssh/bastion_coordinator.rb
phase-0.0.16 lib/phase/kit/ssh/bastion_coordinator.rb
phase-0.0.15 lib/phase/kit/ssh/bastion_coordinator.rb
phase-0.0.14 lib/phase/kit/ssh/bastion_coordinator.rb
phase-0.0.13 lib/phase/kit/ssh/bastion_coordinator.rb
phase-0.0.12 lib/phase/kit/ssh/bastion_coordinator.rb
phase-0.0.11 lib/phase/kit/ssh/bastion_coordinator.rb
phase-0.0.10 lib/phase/kit/ssh/bastion_coordinator.rb
phase-0.0.9 lib/phase/kit/ssh/bastion_coordinator.rb
phase-0.0.8 lib/phase/kit/ssh/bastion_coordinator.rb
phase-0.0.7 lib/phase/kit/ssh/bastion_coordinator.rb
phase-0.0.6 lib/phase/kit/ssh/bastion_coordinator.rb