48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/maws/commands/configure.rb', line 48
def execute_ssh_actions(instances)
threads = []
ssh_connections = {}
instances.each do |instance|
ssh_actions = @ssh_actions[instance]
next if ssh_actions.empty?
threads << Thread.new do
Thread.current[:title] = "#{instance.name} (#{instance.dns_name})"
Thread.current[:ensured_output] = []
ssh = ssh_connect_to(instance)
ssh_connections[instance] = ssh
ssh_actions.each {|action| action.call(ssh)}
ssh_disconnect(ssh, instance)
ssh_connections[instance] = nil
end
end
begin
threads.each do |t|
Kernel.sleep 0.03
t.join
end
ensure
ssh_connections.each do |instance, ssh|
ssh_disconnect(ssh, instance) if ssh
end
print_ensured_output(threads)
end
end
|