Sha256: 972f15d2e5a611d22157e0290e749f73fdfe01d90d745bb781e5077210245137

Contents?: true

Size: 1.19 KB

Versions: 150

Compression:

Stored size: 1.19 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] }]
                                          })
        resource = res.volumes.single_resource(volume_id)
        return resource if resource
        res = ec2_client.describe_volumes({
                                            filters: [{ name: 'tag:Name', values: [volume_id] }]
                                          })
        res.volumes.single_resource(volume_id)
      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

150 entries across 150 versions & 2 rubygems

Version Path
awspec-1.18.2 lib/awspec/helper/finder/ebs.rb
awspec-1.18.1 lib/awspec/helper/finder/ebs.rb
awspec-1.18.0 lib/awspec/helper/finder/ebs.rb
awspec-1.17.4 lib/awspec/helper/finder/ebs.rb
awspec-1.17.3 lib/awspec/helper/finder/ebs.rb
awspec-1.17.2 lib/awspec/helper/finder/ebs.rb
awspec-1.17.1 lib/awspec/helper/finder/ebs.rb
awspec-1.17.0 lib/awspec/helper/finder/ebs.rb
awspec-1.16.1 lib/awspec/helper/finder/ebs.rb
awspec-1.16.0 lib/awspec/helper/finder/ebs.rb
awspec-1.15.3 lib/awspec/helper/finder/ebs.rb
awspec-1.15.2 lib/awspec/helper/finder/ebs.rb
awspec-1.15.1 lib/awspec/helper/finder/ebs.rb
awspec-1.15.0 lib/awspec/helper/finder/ebs.rb
awspec-1.14.1 lib/awspec/helper/finder/ebs.rb
awspec-1.14.0 lib/awspec/helper/finder/ebs.rb
awspec-1.13.0 lib/awspec/helper/finder/ebs.rb
awspec-1.12.7 lib/awspec/helper/finder/ebs.rb
awspec-1.12.6 lib/awspec/helper/finder/ebs.rb
awspec-1.12.5 lib/awspec/helper/finder/ebs.rb