Sha256: ca49d0b59ecb752a1424b1836263b516b60b1449cec80e1e8b5c37817354def1

Contents?: true

Size: 902 Bytes

Versions: 118

Compression:

Stored size: 902 Bytes

Contents

module Awspec::Type
  class Ebs < ResourceBase
    aws_resource Aws::EC2::Volume
    tags_allowed

    def initialize(name)
      super
      @display_name = name
    end

    def resource_via_client
      @resource_via_client ||= find_ebs(@display_name)
    end

    def id
      @id ||= resource_via_client.volume_id if resource_via_client
    end

    STATES = %w(
      creating available in-use deleting deleted error
    )

    STATES.each do |state|
      define_method state.tr('-', '_') + '?' do
        resource_via_client.state == state
      end
    end

    def attached_to?(instance_id)
      instance = find_ec2(instance_id)
      return false unless instance
      return false unless resource_via_client.attachments
      resource_via_client.attachments.first.instance_id == instance.instance_id && \
        resource_via_client.attachments.first.state == 'attached'
    end
  end
end

Version data entries

118 entries across 118 versions & 4 rubygems

Version Path
cthiesfork-awspec-1.2.2 lib/awspec/type/ebs.rb
cthiesfork-awspec-1.2.1 lib/awspec/type/ebs.rb
awspec-1.18.5 lib/awspec/type/ebs.rb
cthiesfork-awspec-1.2.0 lib/awspec/type/ebs.rb
cthiesfork-awspec-1.1.0 lib/awspec/type/ebs.rb
cthiesfork-awspec-1.0.0 lib/awspec/type/ebs.rb
awspec-1.18.4 lib/awspec/type/ebs.rb
awspec-1.18.3 lib/awspec/type/ebs.rb
awspec-1.18.2 lib/awspec/type/ebs.rb
awspec-1.18.1 lib/awspec/type/ebs.rb
awspec-1.18.0 lib/awspec/type/ebs.rb
awspec-1.17.4 lib/awspec/type/ebs.rb
awspec-1.17.3 lib/awspec/type/ebs.rb
awspec-1.17.2 lib/awspec/type/ebs.rb
awspec-1.17.1 lib/awspec/type/ebs.rb
awspec-1.17.0 lib/awspec/type/ebs.rb
awspec-1.16.1 lib/awspec/type/ebs.rb
awspec-1.16.0 lib/awspec/type/ebs.rb
awspec-1.15.3 lib/awspec/type/ebs.rb
awspec-1.15.2 lib/awspec/type/ebs.rb