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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31338e1bb603317a14baafac5806d0b35c96d8f3
4
- data.tar.gz: 8c607dd86439e82816f15cd796b40e30d98e7200
3
+ metadata.gz: 95870592a6aa8d47bc163f61c50bf6db1f1de950
4
+ data.tar.gz: dfd047c6e6a07e96e4759b0ed4c7f6b9576189c3
5
5
  SHA512:
6
- metadata.gz: d8b7af2e22147d25b7949b4d2add78f20036d2934a6af988a49a620a22c8da09b01b981a943413e504abf68cff9524c65a181b0859ca17ed6bd045c95db772fd
7
- data.tar.gz: b2fd5b1272d04be6f8715d4b3eed8d30620bc11a77a85a726bd2941d2668559f9a3d9223be6fb6d788f1f48c4705fcc525d77f86bc8c01a8ad6309b22bc78761
6
+ metadata.gz: efceb65bcafb470813c983a73e84a8c597b20c5b79da6a0d816a0eed515effd671bcd0f78a3765f32804afcbca59ceeb783e8bbdd5f653b81d2417445afe36b7
7
+ data.tar.gz: 15ba5b7b1ffd022f8c0e26763177ca439bdf9ca1a269f524112bb50bb725bd5fb4160cc73de742aecc4e69860473a50a4acbc312582279ba1ec3cb5dc589e83f
@@ -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
- set_prunable(snap)
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 set_prunable(snapshot)
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
- db = find_db
239
- logger.info "Finding most recent snapshot for #{db.id}"
240
- s = db.snapshots.sort_by {|i| i.created_at }.last
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
@@ -1,3 +1,3 @@
1
1
  module Automan
2
- VERSION = "2.2.6"
2
+ VERSION = "2.2.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: automan
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.6
4
+ version: 2.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Chalfant