cucloud 0.7.6 → 0.7.7
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/cucloud.rb +2 -0
- data/lib/cucloud/ec2_utils.rb +2 -4
- data/lib/cucloud/rds_utils.rb +26 -1
- data/lib/cucloud/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77d0bd47f92d489422494497626323e67ee53c2f
|
4
|
+
data.tar.gz: 1c2955b81fb3954b6fb7413906078b98ff318dfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ab4ce9d8144dff9d411c7bffb0f2160686fec8e5a58e848763cb0fd4cd55f9850a16176cfb80fb7bdc822cf1026a2c59fe695fbec694423b08fc92cae2abf49
|
7
|
+
data.tar.gz: c9bea429650b6dc9f8934939fdceeb983f4f06d2cedc33846e900640163421d6d74d5efa280b5da1b826095bc7536431139d8e7f0c370489ae94ba665b2a3e79
|
data/lib/cucloud.rb
CHANGED
data/lib/cucloud/ec2_utils.rb
CHANGED
@@ -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)
|
data/lib/cucloud/rds_utils.rb
CHANGED
@@ -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
|
-
#
|
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.
|
data/lib/cucloud/version.rb
CHANGED
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.
|
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-
|
13
|
+
date: 2017-04-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: aws-sdk
|