automan 2.2.6 → 2.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/automan/rds/snapshot.rb +25 -7
- data/lib/automan/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: 95870592a6aa8d47bc163f61c50bf6db1f1de950
|
4
|
+
data.tar.gz: dfd047c6e6a07e96e4759b0ed4c7f6b9576189c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efceb65bcafb470813c983a73e84a8c597b20c5b79da6a0d816a0eed515effd671bcd0f78a3765f32804afcbca59ceeb783e8bbdd5f653b81d2417445afe36b7
|
7
|
+
data.tar.gz: 15ba5b7b1ffd022f8c0e26763177ca439bdf9ca1a269f524112bb50bb725bd5fb4160cc73de742aecc4e69860473a50a4acbc312582279ba1ec3cb5dc589e83f
|
data/lib/automan/rds/snapshot.rb
CHANGED
@@ -93,8 +93,8 @@ module Automan::RDS
|
|
93
93
|
snap = db.create_snapshot(myname)
|
94
94
|
|
95
95
|
if prune == true
|
96
|
-
logger.info "Setting snapshot to be prunable"
|
97
|
-
|
96
|
+
logger.info "Setting snapshot to be prunable and tagging environment"
|
97
|
+
set_prunable_and_env(snap,environment)
|
98
98
|
end
|
99
99
|
|
100
100
|
if wait_for_completion == true
|
@@ -145,10 +145,10 @@ module Automan::RDS
|
|
145
145
|
end
|
146
146
|
|
147
147
|
# tag with CanPrune
|
148
|
-
def
|
148
|
+
def set_prunable_and_env(snapshot,environment)
|
149
149
|
opts = {
|
150
150
|
resource_name: snapshot_arn(snapshot),
|
151
|
-
tags: [ {key: 'CanPrune', value: 'yes'} ]
|
151
|
+
tags: [ {key: 'CanPrune', value: 'yes'}, {key: 'Environment', value: environment} ]
|
152
152
|
}
|
153
153
|
response = rds.client.add_tags_to_resource opts
|
154
154
|
|
@@ -185,6 +185,15 @@ module Automan::RDS
|
|
185
185
|
tagged_can_prune?(snapshot) && available?(snapshot) && manual?(snapshot)
|
186
186
|
end
|
187
187
|
|
188
|
+
def is_env?(snapshot,environment)
|
189
|
+
tagged_env?(snapshot,environment) && available?(snapshot) && manual?(snapshot)
|
190
|
+
end
|
191
|
+
|
192
|
+
def tagged_env?(snapshot,environment)
|
193
|
+
arn = snapshot_arn(snapshot)
|
194
|
+
tags(arn)['Environment'] == environment
|
195
|
+
end
|
196
|
+
|
188
197
|
def tagged_can_prune?(snapshot)
|
189
198
|
arn = snapshot_arn(snapshot)
|
190
199
|
tags(arn)['CanPrune'] == 'yes'
|
@@ -235,9 +244,18 @@ module Automan::RDS
|
|
235
244
|
|
236
245
|
def latest
|
237
246
|
log_options
|
238
|
-
|
239
|
-
|
240
|
-
|
247
|
+
logger.info "Finding most recent snapshot for #{environment}"
|
248
|
+
|
249
|
+
allsnaps=get_all_snapshots
|
250
|
+
|
251
|
+
envsnaps=[]
|
252
|
+
allsnaps.each do |onesnap|
|
253
|
+
if is_env?(onesnap,environment)
|
254
|
+
envsnaps.push(onesnap)
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
s=envsnaps.sort_by {|i| i.created_at }.last
|
241
259
|
logger.info "Most recent snapshot is #{s.id}"
|
242
260
|
s.id
|
243
261
|
end
|
data/lib/automan/version.rb
CHANGED