Sha256: fdefc8c1ecfb5dafcb8ddd163e72b3af0b4bc7c90e844b630816cda401d2df9f

Contents?: true

Size: 1.97 KB

Versions: 33

Compression:

Stored size: 1.97 KB

Contents

module Fog
  module AWS
    module EC2
      class Real

        require 'fog/aws/parsers/ec2/detach_volume'

        # Detach an Amazon EBS volume from a running instance
        #
        # ==== Parameters
        # * volume_id<~String> - Id of amazon EBS volume to associate with instance
        # * options<~Hash>:
        #   * 'Device'<~String> - Specifies how the device is exposed to the instance (e.g. "/dev/sdh")
        #   * 'Force'<~Boolean> - If true forces detach, can cause data loss/corruption
        #   * 'InstanceId'<~String> - Id of instance to associate volume with
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * 'attachTime'<~Time> - Time of attachment was initiated at
        #     * 'device'<~String> - Device as it is exposed to the instance
        #     * 'instanceId'<~String> - Id of instance for volume
        #     * 'requestId'<~String> - Id of request
        #     * 'status'<~String> - Status of volume
        #     * 'volumeId'<~String> - Reference to volume
        def detach_volume(volume_id, options = {})
          request({
            'Action'    => 'DetachVolume',
            'VolumeId'  => volume_id,
            :idempotent => true,
            :parser     => Fog::Parsers::AWS::EC2::DetachVolume.new
          }.merge!(options))
        end

      end

      class Mock

        def detach_volume(volume_id, options = {})
          response = Excon::Response.new
          response.status = 200
          if (volume = @data[:volumes][volume_id]) && !volume['attachmentSet'].empty?
            data = volume['attachmentSet'].pop
            volume['status'] = 'available'
            response.status = 200
            response.body = {
              'requestId' => Fog::AWS::Mock.request_id
            }.merge!(data)
            response
          else
            raise Fog::AWS::EC2::NotFound.new("The volume '#{volume_id}' does not exist.")
          end
        end

      end
    end
  end
end

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
fog-0.2.30 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.2.28 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.2.27 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.2.26 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.2.25 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.2.24 lib/fog/aws/requests/ec2/detach_volume.rb
tecnh-fog-0.2.23.vpc lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.2.23 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.2.22 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.2.21 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.2.20 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.2.19 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.2.18 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.2.17 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.2.16 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.2.15 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.2.14 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.2.13 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.2.12 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.2.11 lib/fog/aws/requests/ec2/detach_volume.rb