aubergine 0.0.6 → 0.0.7

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: b71615e6febfb431ba5dade675f228246bf019c0
4
- data.tar.gz: 07ae43b9c3735d5f00450f5429e8454eb479e5af
3
+ metadata.gz: f8c748eb0ceea9e180717350d161488a6a2583cb
4
+ data.tar.gz: aae09a118f236dbe68b2fc58386b77c5b130bbda
5
5
  SHA512:
6
- metadata.gz: 12a39c268d2195015d306978a81b5c9890474cef9ec672e0b9367194a2c9c08395028dbd214c3bc2e6345464d3e91a2426243fe0406e33e3cf2a6aa1f177b022
7
- data.tar.gz: fd5942d4ba9c8de2a6a2ab9679474f7373d69dbfaf47dcbed25c0aaef0ea660a6fd361475116f0f5108b55120ba3bb6f626d7917a4aa07a490812de57cf1a612
6
+ metadata.gz: 08ed759c2782b093f9c6cd3da93adb0585ec68ba386973635eefb327b6de8ffc2233568f0fb0371faaecaa186b97ce60de4103ae34aefbe9f8510b5c84223562
7
+ data.tar.gz: 812ff25cc6802bc42c3c04c646e7856b893b40a8d286536d131e7f9affdae7190c726ae924e42c9bc9d2ff7161ee8290b19367ac30a52131afac26d3b0165655
@@ -8,20 +8,24 @@ module Courgette
8
8
  @logger = logger
9
9
  end
10
10
 
11
- def launch!
12
- Parallel.each(client.devices, in_threads: @executors) do |device|
13
- begin
14
- status = client.update_device(device.ip, device.fetch)
15
- logger.info "#{device.ip} #{status}"
16
- rescue Timeout::Error
17
- logger.info "#{device.ip} is unreachable (timeout)"
18
- rescue Net::SSH::Disconnect
19
- logger.info "#{device.ip} is unreachable (disconnect)"
20
- rescue Net::SSH::AuthenticationFailed
21
- logger.info "#{device.ip} credentials are incorrect"
22
- rescue Errno::ECONNREFUSED
23
- logger.info "#{device.ip} is unreachable (connection refused)"
24
- end
11
+ def launch!(filter)
12
+ Parallel.each(client.devices.select { |device| filter.call(device) }, in_threads: @executors) do |device|
13
+ fetch_and_update(device)
14
+ end
15
+ end
16
+
17
+ def fetch_and_update(device)
18
+ begin
19
+ status = client.update_device(device.ip, device.fetch)
20
+ logger.info "#{device.ip} #{status}"
21
+ rescue Timeout::Error
22
+ logger.info "#{device.ip} is unreachable (timeout)"
23
+ rescue Net::SSH::Disconnect
24
+ logger.info "#{device.ip} is unreachable (disconnect)"
25
+ rescue Net::SSH::AuthenticationFailed
26
+ logger.info "#{device.ip} credentials are incorrect"
27
+ rescue Errno::ECONNREFUSED
28
+ logger.info "#{device.ip} is unreachable (connection refused)"
25
29
  end
26
30
  end
27
31
  end
data/lib/courgette.rb CHANGED
@@ -11,7 +11,7 @@ require_relative './courgette/client.rb'
11
11
  require_relative './courgette/executor.rb'
12
12
 
13
13
  module Courgette
14
- def self.run!(aubergine, token, executors = 4, logger = Logger.new(STDOUT))
15
- Executor.new(Client.new(aubergine, token), executors, logger).launch!
14
+ def self.run!(aubergine, token, executors = 4, logger = Logger.new(STDOUT), filter = Proc.new { |device| true })
15
+ Executor.new(Client.new(aubergine, token), executors, logger).launch!(filter)
16
16
  end
17
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aubergine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Guillaume Rose