cucloud 0.7.4 → 0.7.5
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/ec2_utils.rb +17 -4
- 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: 34988a759221260aa910c03f3063f5dc833f5422
|
4
|
+
data.tar.gz: b002d383d5a5766231643a6d9ec214e0c376396c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 359e34085a6474d24686dc2874ac878cea7856be6549afe3d542b35aeb7a8108ecdb2cd5d335f52ef8efbd945385ae1f601e36bd9cb49aa0030c4a2578ab88d9
|
7
|
+
data.tar.gz: 9a9d44ee28bfe4572f0351afe87aea8f2868f013386e6832ec9e454a110ba1b0b84548ecc7235aa533d33ed24a4b38bd9a660dca899ce1df89f032bae539e506
|
data/lib/cucloud/ec2_utils.rb
CHANGED
@@ -179,10 +179,14 @@ module Cucloud
|
|
179
179
|
snapshot_info
|
180
180
|
end
|
181
181
|
|
182
|
-
#
|
182
|
+
# Performs a backup on volumes that do not have a recent snapshot_info
|
183
|
+
# Tags specified in additional_snapshot_tags[] will take precedence over tags we would
|
184
|
+
# normally create or would have copied from the volume via preserve_tags[].
|
183
185
|
# @param days [Integer] defaults to 5
|
186
|
+
# @param preserve_volume_tags [Array] Array of tag keys to copy from from volume, if present.
|
187
|
+
# @param additional_snapshot_tags [Array] Array of hashes containing additional tags to apply,
|
184
188
|
# @return [Array<Hash>] An array of hashes containing snapshot_id, instance_name and volume
|
185
|
-
def backup_volumes_unless_recent_backup(days = 5)
|
189
|
+
def backup_volumes_unless_recent_backup(days = 5, preserve_volume_tags = [], additional_snapshot_tags = [])
|
186
190
|
volumes_backed_up_recently = volumes_with_snapshot_within_last_days(days)
|
187
191
|
snapshots_created = []
|
188
192
|
|
@@ -190,15 +194,24 @@ module Cucloud
|
|
190
194
|
volumes.volumes.each do |volume|
|
191
195
|
next if volumes_backed_up_recently[volume.volume_id.to_s]
|
192
196
|
instance_name = get_instance_name(volume.attachments[0].instance_id)
|
197
|
+
tags = additional_snapshot_tags.dup
|
198
|
+
unless tags.any? { |tagitem| tagitem[:key] == 'Instance Name' }
|
199
|
+
tags << { key: 'Instance Name', value: instance_name }
|
200
|
+
end
|
201
|
+
volume.tags.each do |tag|
|
202
|
+
if preserve_volume_tags.include?(tag.key) && !tags.any? { |tagitem| tagitem[:key] == tag.key }
|
203
|
+
tags << tag
|
204
|
+
end
|
205
|
+
end
|
193
206
|
|
194
|
-
tags = instance_name ? [{ key: 'Instance Name', value: instance_name }] : []
|
195
207
|
snapshot_info = create_ebs_snapshot(volume.volume_id,
|
196
208
|
'auto-ebs-snap-' + Time.now.strftime('%Y-%m-%d-%H:%M:%S'),
|
197
209
|
tags)
|
198
210
|
|
199
211
|
snapshots_created.push(snapshot_id: snapshot_info.snapshot_id,
|
200
212
|
instance_name: instance_name,
|
201
|
-
volume: volume.volume_id
|
213
|
+
volume: volume.volume_id,
|
214
|
+
tags: tags)
|
202
215
|
end
|
203
216
|
|
204
217
|
snapshots_created
|
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.5
|
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-03-
|
13
|
+
date: 2017-03-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: aws-sdk
|