5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/cloudkick/commands/parallel.rb', line 5
def index
unless args.size > 0
raise CommandFailed, 'usage: cloudkick pssh --query <query> ' \
'<command> ' \
'[--username <username>]'
end
query = ('--query')
username = ('--username')
command = args.last.strip rescue nil
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
if username
system("pssh --inline --timeout=-1 --hosts=#{file.path} --user=#{username} '#{command}'")
else
system("pssh --inline --timeout=-1 --hosts=#{file.path} '#{command}'")
end
rescue
raise CommandFailed, 'cloudkick: command not found: pssh'
end
file.close
end
|