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 +4 -4
- data/lib/courgette/executor.rb +18 -14
- data/lib/courgette.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8c748eb0ceea9e180717350d161488a6a2583cb
|
4
|
+
data.tar.gz: aae09a118f236dbe68b2fc58386b77c5b130bbda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08ed759c2782b093f9c6cd3da93adb0585ec68ba386973635eefb327b6de8ffc2233568f0fb0371faaecaa186b97ce60de4103ae34aefbe9f8510b5c84223562
|
7
|
+
data.tar.gz: 812ff25cc6802bc42c3c04c646e7856b893b40a8d286536d131e7f9affdae7190c726ae924e42c9bc9d2ff7161ee8290b19367ac30a52131afac26d3b0165655
|
data/lib/courgette/executor.rb
CHANGED
@@ -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
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|