Sha256: 601b7bdeed14f6a9c6264ad687f0dc237dc4f698e78511cd0c269cb470a91427

Contents?: true

Size: 1.87 KB

Versions: 25

Compression:

Stored size: 1.87 KB

Contents

unless Fog.mocking?

  module Fog
    module AWS
      class EC2

        # 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
          }.merge!(options), Fog::Parsers::AWS::EC2::DetachVolume.new)
        end

      end
    end
  end

else

  module Fog
    module AWS
      class EC2

        def detach_volume(volume_id, options = {})
          response = Excon::Response.new
          response.status = 200
          if volume = Fog::AWS::EC2.data[:volumes][volume_id]
            data = volume['attachmentSet'].pop
            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

25 entries across 25 versions & 1 rubygems

Version Path
fog-0.0.56 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.55 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.54 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.53 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.52 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.51 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.50 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.49 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.48 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.47 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.46 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.45 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.44 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.43 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.42 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.41 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.40 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.39 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.38 lib/fog/aws/requests/ec2/detach_volume.rb
fog-0.0.37 lib/fog/aws/requests/ec2/detach_volume.rb