Sha256: 77b9335adbbd7c8701c6668fffb91313d112b5ea3f39d0a2ef1cefa55b43c1f7

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 KB

Contents

require 'tempfile'

module Cloudkick::Command
  class Pssh < Base
    def index
      unless args.size == 6 or args.size == 8
        raise CommandFailed, 'usage: cloudkick pssh --query <query> ' \
        '--username <username> ' \
        '--output <output> ' \
        '--command <command>'
      end

      query = extract_option('--query')
      username = extract_option('--username')
      output = extract_option('--output')
      command = extract_option('--command')
      
      file = Tempfile.new('ck')

      if query
        client.get('nodes', query).each do |node|
          file.puts node.ipaddress
        end
      else
        client.get('nodes').each do |node|
          file.puts node.ipaddress
        end
      end
      
      file.flush
      begin
        exec("pssh -h #{file.path} -l #{username} -o #{output} #{command}")
      rescue
        raise CommandFailed, 'cloudkick: command not found: pssh'
      end
      file.close
    end
  end

  class Pscp < Base
    def index
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cloudkick-0.2.6 lib/cloudkick/commands/parallel.rb
cloudkick-0.2.5 lib/cloudkick/commands/parallel.rb
cloudkick-0.2.4 lib/cloudkick/commands/parallel.rb
cloudkick-0.2.3 lib/cloudkick/commands/parallel.rb