Sha256: 204b5b6744eee321ae97287fefb1a680677a95385ca728aef7fc24cba88ff88d
Contents?: true
Size: 1.16 KB
Versions: 42
Compression:
Stored size: 1.16 KB
Contents
require 'aws-sdk' require_relative '../../util' module Builderator module Model # :nodoc: module Cleaner def self.volumes @volumes ||= Volumes.new end ## # EC2 Volume Resources ## class Volumes < Model::Cleaner::Base PROPERTIES = %w(size availability_zone state volume_type iops) def fetch @resources = {}.tap do |v| Util.ec2.describe_volumes.each do |page| page.volumes.each do |vol| properties = Util.from_tags(vol.tags) 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 def snapshots resources.values.map { |v| v[:snapshot] } end def in_use {}.tap do |used| used.merge!(select(Cleaner.instances.volumes)) end end end end end end
Version data entries
42 entries across 42 versions & 1 rubygems