Sha256: f8fa0053f8a88d97f38b70864628ac09ca97b663360b660fcbf52e691eff64bd

Contents?: true

Size: 799 Bytes

Versions: 7

Compression:

Stored size: 799 Bytes

Contents

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

    def initialize(id)
      super
      @resource_via_client = find_ebs(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

7 entries across 7 versions & 1 rubygems

Version Path
awspec-0.55.0 lib/awspec/type/ebs.rb
awspec-0.54.0 lib/awspec/type/ebs.rb
awspec-0.52.4 lib/awspec/type/ebs.rb
awspec-0.52.3 lib/awspec/type/ebs.rb
awspec-0.52.2 lib/awspec/type/ebs.rb
awspec-0.52.1 lib/awspec/type/ebs.rb
awspec-0.52.0 lib/awspec/type/ebs.rb