Sha256: 84fa33e56f6fd421b649663f3d5ecfcc76bea2ee99d6b20ed7923710977af915

Contents?: true

Size: 1.63 KB

Versions: 39

Compression:

Stored size: 1.63 KB

Contents

module Fog
  module Rackspace
    class BlockStorage
      class Real
        # Delete volume
        #
        # @param [String] volume_id Id of volume to delete
        # @return [Excon::Response] response
        # @raise [Fog::Rackspace::BlockStorage::NotFound] - HTTP 404
        # @raise [Fog::Rackspace::BlockStorage::BadRequest] - HTTP 400
        # @raise [Fog::Rackspace::BlockStorage::InternalServerError] - HTTP 500
        # @raise [Fog::Rackspace::BlockStorage::ServiceError]
        # @note You cannot delete a volume until all of its dependent snaphosts have been deleted.
        # @see http://docs.rackspace.com/cbs/api/v1.0/cbs-devguide/content/DELETE_deleteVolume__v1__tenant_id__volumes.html
        def delete_volume(volume_id)
          request(
            :expects => [202],
            :method => 'DELETE',
            :path => "volumes/#{volume_id}"
          )
        end
      end

      class Mock
        def delete_volume(volume_id)
          volume = self.data[:volumes][volume_id]
          snapshots = self.data[:snapshots].values.select { |s| s["volume_id"] == volume_id }
          raise Fog::Rackspace::BlockStorage::BadRequest.new("Volume still has #{snapshots.count} dependent snapshots") if !snapshots.empty?
          unless volume.nil?
            unless volume["attachments"].empty?
              raise Fog::Rackspace::BlockStorage::BadRequest.new("Volume status must be available or error")
            end
            self.data[:volumes].delete(volume_id)
            response(:status => 202)
          else
            raise Fog::Rackspace::BlockStorage::NotFound
          end
        end
      end
    end
  end
end

Version data entries

39 entries across 37 versions & 6 rubygems

Version Path
fog-rackspace-0.1.6 lib/fog/rackspace/requests/block_storage/delete_volume.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-rackspace-0.1.5/lib/fog/rackspace/requests/block_storage/delete_volume.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-rackspace-0.1.5/lib/fog/rackspace/requests/block_storage/delete_volume.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-rackspace-0.1.5/lib/fog/rackspace/requests/block_storage/delete_volume.rb
fog-rackspace-0.1.5 lib/fog/rackspace/requests/block_storage/delete_volume.rb
fog-rackspace-0.1.4 lib/fog/rackspace/requests/block_storage/delete_volume.rb
fog-rackspace-0.1.3 lib/fog/rackspace/requests/block_storage/delete_volume.rb
fog-rackspace-0.1.2 lib/fog/rackspace/requests/block_storage/delete_volume.rb
fog-rackspace-0.1.1 lib/fog/rackspace/requests/block_storage/delete_volume.rb
fog-rackspace-0.1.0 lib/fog/rackspace/requests/block_storage/delete_volume.rb
fog-1.37.0 lib/fog/rackspace/requests/block_storage/delete_volume.rb
fog-1.36.0 lib/fog/rackspace/requests/block_storage/delete_volume.rb
fog-1.35.0 lib/fog/rackspace/requests/block_storage/delete_volume.rb
fog-2.0.0.pre.0 lib/fog/rackspace/requests/block_storage/delete_volume.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/rackspace/requests/block_storage/delete_volume.rb
fog-1.34.0 lib/fog/rackspace/requests/block_storage/delete_volume.rb
fog-1.33.0 lib/fog/rackspace/requests/block_storage/delete_volume.rb
fog-1.32.0 lib/fog/rackspace/requests/block_storage/delete_volume.rb
fog-1.31.0 lib/fog/rackspace/requests/block_storage/delete_volume.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/rackspace/requests/block_storage/delete_volume.rb