cucloud 0.7.6 → 0.7.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: b9c097b02b7b8ee93f6adb3be2c80ea3e859b767
4
- data.tar.gz: 7e35d979d839416122e5b42a7805de6481afb2f5
3
+ metadata.gz: 77d0bd47f92d489422494497626323e67ee53c2f
4
+ data.tar.gz: 1c2955b81fb3954b6fb7413906078b98ff318dfd
5
5
  SHA512:
6
- metadata.gz: d2be8ee2db184cf7b875764c83ee0fc01820710741fe981ffb73c95d93cb4a42c0f29d4459d8f4a255127df4448de5b8321ad46a8d1fdd142a5522a2cccca49b
7
- data.tar.gz: 5d91d37eaa27392c7420458bb97d43caffa9502667701b366606ba6c1431c1582428b6dce2317ecfa5fb5724b5ca3e2d8906b73fd79eda2f33e8a9a69101a4fc
6
+ metadata.gz: 2ab4ce9d8144dff9d411c7bffb0f2160686fec8e5a58e848763cb0fd4cd55f9850a16176cfb80fb7bdc822cf1026a2c59fe695fbec694423b08fc92cae2abf49
7
+ data.tar.gz: c9bea429650b6dc9f8934939fdceeb983f4f06d2cedc33846e900640163421d6d74d5efa280b5da1b826095bc7536431139d8e7f0c370489ae94ba665b2a3e79
@@ -20,6 +20,8 @@ module Cucloud
20
20
 
21
21
  # This is the default region API calls are made against
22
22
  DEFAULT_REGION = 'us-east-1'.freeze
23
+ # Used in time calculations
24
+ SECONDS_IN_A_DAY = 86_400
23
25
 
24
26
  Aws.config = { region: DEFAULT_REGION }
25
27
 
@@ -5,8 +5,6 @@ module Cucloud
5
5
  UBUNTU_PATCH_COMMAND = 'apt-get update; apt-get -y upgrade; reboot'.freeze
6
6
  # This is the command sent to amazon linux machines for patching
7
7
  AMAZON_PATCH_COMMAND = 'yum update -y; reboot & disown '.freeze
8
- # Used in time calculations
9
- SECONDS_IN_A_DAY = 86_400
10
8
  # Max attemps for a waiter to try
11
9
  WAITER_MAX_ATTEMPS = 240
12
10
  # Delay between calls used by waiter to check status
@@ -229,7 +227,7 @@ module Cucloud
229
227
 
230
228
  snapshots = @ec2.describe_snapshots(owner_ids: ['self'], filters: [{ name: 'status', values: ['completed'] }])
231
229
  snapshots.snapshots.each do |snapshot|
232
- if snapshot.start_time > Time.now - (SECONDS_IN_A_DAY * days)
230
+ if snapshot.start_time > Time.now - (Cucloud::SECONDS_IN_A_DAY * days)
233
231
  volumes_backed_up_recently[snapshot.volume_id.to_s] = true
234
232
  end
235
233
  end
@@ -246,7 +244,7 @@ module Cucloud
246
244
 
247
245
  snapshots.snapshots.each do |snapshot|
248
246
  if !days_old.nil?
249
- snapshot_days_old = (Time.now.to_i - snapshot.start_time.to_i) / SECONDS_IN_A_DAY
247
+ snapshot_days_old = (Time.now.to_i - snapshot.start_time.to_i) / Cucloud::SECONDS_IN_A_DAY
250
248
 
251
249
  if snapshot_days_old > days_old
252
250
  found_snapshots.push(snapshot.snapshot_id)
@@ -86,8 +86,9 @@ module Cucloud
86
86
  @rds.wait_until(:db_instance_available, db_instance_identifier: db_instance_identifier)
87
87
  end
88
88
 
89
- # Delete a givne db instance
89
+ # Find the latest snapshot for a given RDS instance
90
90
  # @param db_instance_identifier [String] RDS instance identifier
91
+ # @param snapshot_type [String] One of the following types public, shared, manual or automated
91
92
  # @return [String] Most recent snapshot ID for given RDS instance
92
93
  def find_latest_snapshot(db_instance_identifier, snapshot_type = 'manual')
93
94
  latest_snapshot_time = Time.new(2002)
@@ -170,6 +171,30 @@ module Cucloud
170
171
  wait_until_snapshot_available(snap, nil, 10)
171
172
  end
172
173
 
174
+ # Find RDS Snapshot older than supplied days
175
+ # @param options [Hash] User specified search options
176
+ # @param snapshot_type [String] One of the following types public, shared, manual or automated
177
+ # @return [String] Most recent snapshot ID for given RDS instance
178
+ def find_rds_snapshots(options = {}, snapshot_type = 'manual')
179
+ days_old = options[:days_old]
180
+ found_snap_shots = []
181
+
182
+ snapshots_info = @rds.describe_db_snapshots(snapshot_type: snapshot_type)[:db_snapshots]
183
+
184
+ snapshots_info.each do |snapshot_info|
185
+ next if snapshot_info[:status] != 'available'
186
+ if !days_old.nil?
187
+ snapshot_days_old = (Time.now.to_i - snapshot_info[:snapshot_create_time].to_i) / Cucloud::SECONDS_IN_A_DAY
188
+ if snapshot_days_old > days_old
189
+ found_snap_shots.push(snapshot_info[:db_snapshot_identifier])
190
+ end
191
+ else
192
+ found_snap_shots.push(snapshot_info[:db_snapshot_identifier])
193
+ end
194
+ end
195
+ found_snap_shots
196
+ end
197
+
173
198
  private
174
199
 
175
200
  # Return the given non-negative number as a string, zero-padded to 2 digits.
@@ -1,5 +1,5 @@
1
1
  module Cucloud
2
2
  # Disable mutable constant warning - freezing this oddly breaks bundler
3
3
  # rubocop:disable Style/MutableConstant
4
- VERSION = '0.7.6'
4
+ VERSION = '0.7.7'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.6
4
+ version: 0.7.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - sbower
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2017-04-04 00:00:00.000000000 Z
13
+ date: 2017-04-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: aws-sdk