Sha256: 28b026085ba9cca5a6764684d3a274af1091ba437868fc5032b49942571a8705

Contents?: true

Size: 855 Bytes

Versions: 4

Compression:

Stored size: 855 Bytes

Contents

module Fog
  module Compute
    class OpenStack
      class Real
        def detach_volume(server_id, attachment_id)
          request(
            :expects  => 202,
            :method   => 'DELETE',
            :path     => "servers/%s/os-volume_attachments/%s" % [server_id, attachment_id]
          )
        end
      end

      class Mock
        def detach_volume(server_id, attachment_id)
          response = Excon::Response.new
          if self.data[:volumes][attachment_id] &&
             self.data[:volumes][attachment_id]['attachments'].reject! { |attachment| attachment['serverId'] == server_id }
            data[:volumes][attachment_id]['status'] = 'available'
            response.status = 202
            response
          else
            raise Fog::Compute::OpenStack::NotFound
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-openstack-0.1.10 lib/fog/openstack/requests/compute/detach_volume.rb
fog-openstack-0.1.9 lib/fog/openstack/requests/compute/detach_volume.rb
fog-openstack-0.1.8 lib/fog/openstack/requests/compute/detach_volume.rb
fog-openstack-0.1.7 lib/fog/openstack/requests/compute/detach_volume.rb