Sha256: 61fb4d43e3ce4703c9843ef83b997d0dd31c4369a2adeb34b815c9818de22f55

Contents?: true

Size: 680 Bytes

Versions: 8

Compression:

Stored size: 680 Bytes

Contents

module Awspec::Type
  class Ebs < Base
    def initialize(id)
      super
      @resource = find_ebs(id)
      @id = @resource[:volume_id] if @resource
    end

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

    STATES.each do |state|
      define_method state.tr('-', '_') + '?' do
        @resource[:state] == state
      end
    end

    def attached_to?(instance_id)
      instance = find_ec2(instance_id)
      return false unless instance
      return false unless @resource[:attachments]
      @resource[:attachments][0][:instance_id] == instance[:instance_id] && \
        @resource[:attachments][0][:state] == 'attached'
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
awspec-0.25.3 lib/awspec/type/ebs.rb
awspec-0.25.2 lib/awspec/type/ebs.rb
awspec-0.25.1 lib/awspec/type/ebs.rb
awspec-0.25.0 lib/awspec/type/ebs.rb
awspec-0.24.2 lib/awspec/type/ebs.rb
awspec-0.24.1 lib/awspec/type/ebs.rb
awspec-0.24.0 lib/awspec/type/ebs.rb
awspec-0.23.0 lib/awspec/type/ebs.rb