octosh 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ gem 'net-ssh', '2.6.1'
4
4
  gem 'net-scp', '1.0.4'
5
5
  gem 'highline', '1.6.15'
6
6
  gem 'uuid', '2.3.5'
7
+ gem 'parallel', '0.5.19'
7
8
 
8
9
  group :test do
9
10
  gem 'rake', '0.9.2.2'
data/Gemfile.lock CHANGED
@@ -3,9 +3,12 @@ GEM
3
3
  specs:
4
4
  diff-lcs (1.1.3)
5
5
  highline (1.6.15)
6
+ macaddr (1.6.1)
7
+ systemu (~> 2.5.0)
6
8
  net-scp (1.0.4)
7
9
  net-ssh (>= 1.99.1)
8
10
  net-ssh (2.6.1)
11
+ parallel (0.5.19)
9
12
  rake (0.9.2.2)
10
13
  rspec (2.12.0)
11
14
  rspec-core (~> 2.12.0)
@@ -15,6 +18,9 @@ GEM
15
18
  rspec-expectations (2.12.0)
16
19
  diff-lcs (~> 1.1.3)
17
20
  rspec-mocks (2.12.0)
21
+ systemu (2.5.2)
22
+ uuid (2.3.5)
23
+ macaddr (~> 1.0)
18
24
 
19
25
  PLATFORMS
20
26
  ruby
@@ -23,6 +29,8 @@ DEPENDENCIES
23
29
  highline (= 1.6.15)
24
30
  net-scp (= 1.0.4)
25
31
  net-ssh (= 2.6.1)
32
+ parallel (= 0.5.19)
26
33
  rake (= 0.9.2.2)
27
34
  rspec (= 2.12.0)
28
35
  rspec-mocks (= 2.12.0)
36
+ uuid (= 2.3.5)
data/lib/octosh/cli.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'optparse'
2
2
  require 'ostruct'
3
+ require 'parallel'
3
4
 
4
5
  $:.push File.dirname(__FILE__) + '../'
5
6
  require 'octosh'
@@ -108,6 +109,8 @@ module Octosh
108
109
  end
109
110
 
110
111
  def self.inline_bash(hosts, bash, user, password_prompt=true, uniform_password=false)
112
+ workers = []
113
+
111
114
  hosts.each do |host|
112
115
  prompt_for_password(password_prompt, uniform_password)
113
116
  exec_user,hostname = ""
@@ -119,12 +122,17 @@ module Octosh
119
122
  hostname = host
120
123
  end
121
124
  worker = Octosh::Worker.new(hostname, exec_user, @password)
122
-
123
- puts "#{host} -- #{worker.exec(bash)}"
125
+ workers << worker
126
+ end
127
+
128
+ Parallel.each(workers, :in_threads => workers.length) do |worker|
129
+ puts "#{worker.host} -- #{worker.exec(bash)}"
124
130
  end
125
131
  end
126
132
 
127
133
  def self.exec_script(hosts, script, user, password_prompt=true, uniform_password=false)
134
+ workers = []
135
+
128
136
  hosts.each do |host|
129
137
  prompt_for_password(password_prompt, uniform_password)
130
138
  exec_user,hostname = ""
@@ -136,8 +144,13 @@ module Octosh
136
144
  hostname = host
137
145
  end
138
146
  worker = Octosh::Worker.new(hostname, exec_user, @password)
139
- puts "#{host} -- #{worker.exec_script(script)}"
147
+ workers << worker
148
+ end
149
+
150
+ Parallel.each(workers, :in_threads => workers.length) do |worker|
151
+ puts "#{worker.host} -- #{worker.exec_script(script)}"
140
152
  end
153
+
141
154
  end
142
155
 
143
156
  end
@@ -1,3 +1,3 @@
1
1
  module Octosh
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -17,7 +17,25 @@ module Octosh
17
17
  end
18
18
 
19
19
  def exec(command)
20
- return @ssh.exec!(command)
20
+ channel = @ssh.open_channel do |ch|
21
+ ch.exec(command) do |ch, success|
22
+ raise "Error executing #{command}" unless success
23
+
24
+ ch.on_data do |c, data|
25
+ puts "#{@host} -- #{data.to_s}"
26
+ end
27
+
28
+ ch.on_extended_data do |c, type, data|
29
+ puts "#{@host} -- #{data}"
30
+ end
31
+
32
+ ch.on_close do
33
+ puts "Octosh execution complete!"
34
+ end
35
+ end
36
+ end
37
+
38
+ channel.wait
21
39
  end
22
40
 
23
41
  def put(local_path, remote_path)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octosh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: