bunka 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2f4ae862ed5def414a479c371c79c4da80695b5
4
- data.tar.gz: 26ecab7c3a36d9422d0dfc42b0d53dbb7df4387e
3
+ metadata.gz: 7ea509355512cd6fe9f244e9412e4090f2845a32
4
+ data.tar.gz: d73ab4d22d8018311246d6bba7cd146e699337c1
5
5
  SHA512:
6
- metadata.gz: a44cb8758b185129f890a7e91b67c12aae9ad9969d205e65050007b0a261c5f1aadbd3cf98f4273dcbce43fb1aa85dcd433a8409c491118252648e117ab84bda
7
- data.tar.gz: c4ef94336c0838f4abd32ec522707efa7e4b43ba245e2cc03988d01aa5941313bc59bca2a30f38b264ce3be4ae0ba6e60276953f68d56146ceb1d1bb9468785f
6
+ metadata.gz: 8a346a2846218bf64a1b24ada95601e2955d076b7c60e037d767e7e098366545e46256a8dffae97fe7aedcddaa0d44d869ad517f60f2932e9e110dbd22733cab
7
+ data.tar.gz: d1109c881b61c9d7e9a8bbfa0d8bb00cfdb6bf12d9d1a4dc36d0d612a160ff54397033be8aa209e228179154aff1f83193aed8704a0465b0e90cc274494331f0
data/bin/bunka CHANGED
@@ -12,8 +12,9 @@ class BunkaCommand < Thor
12
12
  option :timeout, type: :numeric, desc: 'timeout interval per ssh connection (default: 15)', default: 15
13
13
  option :threads, type: :numeric, desc: 'number of threads (default: 15)', default: 15
14
14
  option :'print-success', type: :boolean, desc: 'prints output of successful commands', default: false
15
+ option :'from-file', type: :string, desc: 'path to file with list of servers', default: nil
15
16
  def test(command, query='name:*')
16
- Bunka.test(command, query, options[:timeout], options[:'print-success'], options[:invert], options[:sequential], options[:threads])
17
+ Bunka.test(command, query, options[:timeout], options[:'print-success'], options[:invert], options[:sequential], options[:threads], options[:'from-file'])
17
18
  end
18
19
  end
19
20
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'bunka'
3
- spec.version = '1.3.0'
3
+ spec.version = '1.4.0'
4
4
  spec.executables << 'bunka'
5
5
  spec.date = '2013-11-26'
6
6
  spec.summary = 'Parallel ssh commands over chef servers with rspec-like output'
@@ -1,30 +1,25 @@
1
1
  require 'parallel'
2
2
 
3
+ require 'bunka/bunka'
3
4
  require 'bunka/chef'
4
5
  require 'bunka/helpers'
5
6
  require 'bunka/printers'
6
- require 'bunka/bunka'
7
7
  require 'bunka/ssh'
8
8
 
9
9
  class Bunka
10
10
  class << self
11
- def test command, query, timeout_interval, verbose_success, invert, sequential, threads
11
+ def test command, query, timeout_interval, verbose_success, invert, sequential, threads, file=nil
12
12
  @command = command
13
13
  @invert = invert
14
14
  @query = query
15
15
  @sequential = sequential
16
- @threads = threads
16
+ @threads = sequential ? 1 : threads
17
17
  @timeout_interval = timeout_interval
18
18
  @verbose_success = verbose_success
19
+ @file = file
19
20
 
20
- if sequential
21
- knife_search(@query).each do |fqdn|
22
- execute_query fqdn
23
- end
24
- else
25
- Parallel.map(knife_search(@query), in_threads: @threads) do |fqdn|
26
- execute_query fqdn
27
- end
21
+ Parallel.map(nodes, in_threads: @threads) do |fqdn|
22
+ execute_query fqdn
28
23
  end
29
24
 
30
25
  print_summary
@@ -2,6 +2,14 @@ require 'net/ssh'
2
2
 
3
3
  class Bunka
4
4
  class << self
5
+ def nodes
6
+ if @file
7
+ File.readlines(@file).collect(&:strip)
8
+ else
9
+ knife_search(@query)
10
+ end
11
+ end
12
+
5
13
  def execute_query fqdn
6
14
  begin
7
15
  timeout @timeout_interval do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bunka
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven De Coeyer