Sha256: 059a1ea22367ab7953c20045871fec7537e6f31686ffb9c1960e8d7500bfd83a

Contents?: true

Size: 946 Bytes

Versions: 1

Compression:

Stored size: 946 Bytes

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> ' \
        '--command <command>'
      end

      query = extract_option('--query')
      username = extract_option('--username')
      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
        system("pssh -i -h #{file.path} -l #{username} '#{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

1 entries across 1 versions & 1 rubygems

Version Path
cloudkick-0.2.8 lib/cloudkick/commands/parallel.rb