Sha256: d89923f7981cb2982e0a0d16a4cd3e22af2ec60636f2e9105e801f7d27731033

Contents?: true

Size: 1.91 KB

Versions: 18

Compression:

Stored size: 1.91 KB

Contents

module Fog
  module AWS
    module EC2
      class Real

        # 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,
            :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)
          else
            response.status = 400
            raise(Excon::Errors.status_error({:expects => 200}, response))
          end
          response
        end

      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
fog-0.1.1 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.1.0 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.100 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.99 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.98 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.97 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.96 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.95 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.94 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.93 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.92 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.91 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.90 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.89 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.88 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.87 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.86 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.85 lib/fog/aws/requests/ec2/detach_volume.rb