Sha256: 6d03dcc1dc4a51e6738d94252c9b8a9fcbf88d7e9e07dc698e4678c583187c03
Contents?: true
Size: 1.17 KB
Versions: 10
Compression:
Stored size: 1.17 KB
Contents
module Awspec::Helper module Finder module Ebs def find_ebs(volume_id) res = ec2_client.describe_volumes({ filters: [{ name: 'volume-id', values: [volume_id] }] }) return res[:volumes].first if res[:volumes].count == 1 res = ec2_client.describe_volumes({ filters: [{ name: 'tag:Name', values: [volume_id] }] }) return res[:volumes].first if res[:volumes].count == 1 end def select_ebs_by_instance_id(id) res = find_ec2(id) volumes = [] return volumes unless res res[:block_device_mappings].each do |block| volume = find_ebs(block.ebs.volume_id) volumes.push(volume) if volume end volumes end def select_all_attached_ebs selected = [] res = ec2_client.describe_volumes loop do selected += res.volumes.select { |v| v.attachments.count > 0 } (res.next_page? && res = res.next_page) || break end selected end end end end
Version data entries
10 entries across 10 versions & 1 rubygems