cucloud 0.7.4 → 0.7.5

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: e0ec7bb76b35852525278900952ba8a595085bcf
4
- data.tar.gz: 885960dcb92af67a402bfbcccc8ae32eb77f3a20
3
+ metadata.gz: 34988a759221260aa910c03f3063f5dc833f5422
4
+ data.tar.gz: b002d383d5a5766231643a6d9ec214e0c376396c
5
5
  SHA512:
6
- metadata.gz: 02e22a020ab6c0541e3b28c2063585284e24260f423eb0d620f1384d4c28f8e736418f256c14c39337278ce77773a1b07f5aa18fd642dac4e5717037124cb08d
7
- data.tar.gz: dbc7c489fc8f3792c6a345ffb87c8297635f6fd9ba4a6d13fc5ab083e1baab3409366f62ba6ebed58d7f14ea31cb80d0d43c7b57d5f24b58e93fbd7591823ef5
6
+ metadata.gz: 359e34085a6474d24686dc2874ac878cea7856be6549afe3d542b35aeb7a8108ecdb2cd5d335f52ef8efbd945385ae1f601e36bd9cb49aa0030c4a2578ab88d9
7
+ data.tar.gz: 9a9d44ee28bfe4572f0351afe87aea8f2868f013386e6832ec9e454a110ba1b0b84548ecc7235aa533d33ed24a4b38bd9a660dca899ce1df89f032bae539e506
@@ -179,10 +179,14 @@ module Cucloud
179
179
  snapshot_info
180
180
  end
181
181
 
182
- # Preforms a backup on volumes that do not have a recent snapshot_info
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
@@ -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.4'
4
+ VERSION = '0.7.5'
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.4
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-10 00:00:00.000000000 Z
13
+ date: 2017-03-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: aws-sdk