Class: Builderator::Model::Cleaner::Snapshots

Inherits:
Base
  • Object
show all
Defined in:
lib/builderator/model/cleaner/snapshots.rb

Overview

EC2 Snapshot Resources

Constant Summary collapse

PROPERTIES =
%w(state owner_id description volume_size)

Instance Attribute Summary

Attributes inherited from Base

#resources

Instance Method Summary collapse

Methods inherited from Base

#find, #in_use?, #initialize, #select, #unused

Constructor Details

This class inherits a constructor from Builderator::Model::Cleaner::Base

Instance Method Details

#fetchObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/builderator/model/cleaner/snapshots.rb', line 18

def fetch
  @resources = {}.tap do |s|
    Util.ec2.describe_snapshots(:filters => [
      {
        :name => 'status',
        :values => %w(completed)
      }
    ], :owner_ids => ['self']).each do |page|
      page.snapshots.each do |snap|
        properties = Util.from_tags(snap.tags)
        properties['creation_date'] = snap.start_time.to_datetime
        PROPERTIES.each { |pp| properties[pp] = snap[pp.to_sym] }

        s[snap.snapshot_id] = {
          :id => snap.snapshot_id,
          :properties => properties,
          :volume => snap.volume_id
        }
      end
    end
  end
end

#in_useObject



41
42
43
44
45
46
# File 'lib/builderator/model/cleaner/snapshots.rb', line 41

def in_use
  {}.tap do |used|
    used.merge!(select(Cleaner.volumes.snapshots))
    used.merge!(select(Cleaner.images.snapshots))
  end
end