puppetdb_query 0.0.16 → 0.0.17
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.
- checksums.yaml +4 -4
- data/lib/puppetdb_query/mongodb.rb +2 -0
- data/lib/puppetdb_query/sync.rb +17 -1
- data/lib/puppetdb_query/version.rb +1 -1
- 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: 507f8e5698421bc168bb7f4dc02b43303a6e1cd2
|
4
|
+
data.tar.gz: b11e7dfbf489f5c56bdd72dd5f3b379381bf9ffc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 613d3f07ad16860026e68300e9b6b2d0c56e8ddc85d935b1a947de55a9770cf3c9c3430eca5393961ea1ca1be746a44cd7eb9d06cbce75904e5ddafc2660eaa4
|
7
|
+
data.tar.gz: 1d378d330ca704324bc19105266c3f887d8e779371cc9dde6a656de82f497115051cbd559311a13116f14e3b1244bceb3ba67e16297eb7a8dff47d0cb174139d
|
@@ -10,6 +10,7 @@ module PuppetDBQuery
|
|
10
10
|
attr_reader :nodes_collection
|
11
11
|
attr_reader :node_properties_collection
|
12
12
|
attr_reader :meta_collection
|
13
|
+
attr_reader :node_properties_update_timestamp
|
13
14
|
|
14
15
|
# initialize access to mongodb
|
15
16
|
#
|
@@ -161,6 +162,7 @@ module PuppetDBQuery
|
|
161
162
|
},
|
162
163
|
{ upsert: true }
|
163
164
|
)
|
165
|
+
@node_properties_update_timestamp = ts_begin
|
164
166
|
end
|
165
167
|
end
|
166
168
|
end
|
data/lib/puppetdb_query/sync.rb
CHANGED
@@ -16,7 +16,6 @@ module PuppetDBQuery
|
|
16
16
|
|
17
17
|
def sync(minutes = 60, seconds = 10)
|
18
18
|
logger.info "syncing puppetdb nodes and facts started, running #{minutes} minutes"
|
19
|
-
|
20
19
|
Timeout.timeout(60 * minutes - seconds) do
|
21
20
|
updater = PuppetDBQuery::Updater.new(source, destination)
|
22
21
|
|
@@ -27,6 +26,7 @@ module PuppetDBQuery
|
|
27
26
|
# make delta updates til our time is up
|
28
27
|
loop do
|
29
28
|
begin
|
29
|
+
check_minutely
|
30
30
|
ts = Time.now
|
31
31
|
updater.update3(timestamp - 2)
|
32
32
|
timestamp = ts
|
@@ -46,5 +46,21 @@ module PuppetDBQuery
|
|
46
46
|
rescue
|
47
47
|
logger.error $!
|
48
48
|
end
|
49
|
+
|
50
|
+
# this method is called
|
51
|
+
def minutely
|
52
|
+
logger.info "node_properties update timestamp:" \
|
53
|
+
" #{destination.node_properties_update_timestamp}"
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def check_minutely
|
59
|
+
@last_minute ||= Time.now - 60
|
60
|
+
timestamp = Time.now
|
61
|
+
return if timestamp - 60 < @last_minute
|
62
|
+
minutely
|
63
|
+
@last_minute = timestamp
|
64
|
+
end
|
49
65
|
end
|
50
66
|
end
|