Class: Builderator::Model::Volumes
- Defined in:
- lib/builderator/model/volumes.rb
Overview
EC2 Volume Resources
Constant Summary collapse
- LIMIT =
8- PROPERTIES =
%w(size availability_zone state volume_type iops)
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#find, #initialize, #reject, #select, #unused
Constructor Details
This class inherits a constructor from Builderator::Model::Base
Instance Method Details
#fetch ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/builderator/model/volumes.rb', line 18 def fetch @resources = {}.tap do |v| Util.ec2.describe_volumes.each do |page| page.volumes.each do |vol| properties = Util.(vol.) properties['creation_date'] = vol.create_time.to_datetime PROPERTIES.each { |pp| properties[pp] = vol[pp.to_sym] } v[vol.volume_id] = { :id => vol.volume_id, :properties => properties, :snapshot => vol.snapshot_id } end end end end |
#in_use(_) ⇒ Object
41 42 43 44 45 |
# File 'lib/builderator/model/volumes.rb', line 41 def in_use(_) {}.tap do |used| used.merge!(select(Model.instances.volumes)) end end |
#snapshots ⇒ Object
37 38 39 |
# File 'lib/builderator/model/volumes.rb', line 37 def snapshots resources.values.map { |v| v[:snapshot] } end |