Class: EbsPruneSnapshot::Base
- Inherits:
-
Object
- Object
- EbsPruneSnapshot::Base
- Defined in:
- lib/ebs_prune_snapshot.rb
Instance Attribute Summary collapse
-
#aws ⇒ Object
readonly
Returns the value of attribute aws.
-
#rotation ⇒ Object
readonly
Returns the value of attribute rotation.
Instance Method Summary collapse
- #describe ⇒ Object
- #describe_volume(volume_id) ⇒ Object
-
#initialize(args = {}) ⇒ Base
constructor
A new instance of Base.
- #prune ⇒ Object
- #prune_volume(volume_id) ⇒ Object
- #volume(volume_id) ⇒ Object
- #volumes ⇒ Object
Constructor Details
Instance Attribute Details
#aws ⇒ Object (readonly)
Returns the value of attribute aws.
7 8 9 |
# File 'lib/ebs_prune_snapshot.rb', line 7 def aws @aws end |
#rotation ⇒ Object (readonly)
Returns the value of attribute rotation.
7 8 9 |
# File 'lib/ebs_prune_snapshot.rb', line 7 def rotation @rotation end |
Instance Method Details
#describe ⇒ Object
30 31 32 33 |
# File 'lib/ebs_prune_snapshot.rb', line 30 def describe puts rotation volumes.keys.each { |volume_id| describe_volume(volume_id) } end |
#describe_volume(volume_id) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/ebs_prune_snapshot.rb', line 39 def describe_volume(volume_id) analyzer = SnapshotAnalyzer.new(volume(volume_id), rotation) puts "VOLUME: #{volume_id}" analyzer.to_skip.each {|snapshot| puts " SKIP: #{snapshot.snapshot_id} : #{snapshot.date}"} analyzer.to_save.each {|snapshot| puts " KEEP: #{snapshot.snapshot_id} : #{snapshot.date}"} analyzer.to_delete.each {|snapshot| puts " DELE: #{snapshot.snapshot_id} : #{snapshot.date}"} end |
#prune ⇒ Object
35 36 37 |
# File 'lib/ebs_prune_snapshot.rb', line 35 def prune volumes.keys.each { |volume_id| prune_volume(volume_id) } end |
#prune_volume(volume_id) ⇒ Object
47 48 49 50 |
# File 'lib/ebs_prune_snapshot.rb', line 47 def prune_volume(volume_id) analyzer = SnapshotAnalyzer.new(volume(volume_id), rotation) analyzer.to_delete.each { |snapshot| aws.delete(snapshot) } end |
#volume(volume_id) ⇒ Object
26 27 28 |
# File 'lib/ebs_prune_snapshot.rb', line 26 def volume(volume_id) volumes[volume_id] end |
#volumes ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ebs_prune_snapshot.rb', line 14 def volumes @volumes ||= begin volumes = {} aws.snapshots.each do |snapshot| _snapshot = Snapshot.new(snapshot) volumes[_snapshot.volume_id] ||= [] volumes[_snapshot.volume_id].push(_snapshot) end volumes end end |