2010-03-16 15:46:21 -07:00
|
|
|
module Fog
|
|
|
|
module AWS
|
2010-09-08 14:40:02 -07:00
|
|
|
class Compute
|
2010-03-16 15:46:21 -07:00
|
|
|
class Real
|
2009-08-15 15:19:07 -07:00
|
|
|
|
2011-02-23 11:05:14 +08:00
|
|
|
require 'fog/compute/parsers/aws/basic'
|
|
|
|
|
2009-08-15 15:19:07 -07:00
|
|
|
# Delete an EBS volume
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * volume_id<~String> - Id of volume to delete.
|
|
|
|
#
|
|
|
|
# ==== Returns
|
2009-11-02 18:48:49 -08:00
|
|
|
# * response<~Excon::Response>:
|
2009-08-15 15:19:07 -07:00
|
|
|
# * body<~Hash>:
|
|
|
|
# * 'requestId'<~String> - Id of request
|
|
|
|
# * 'return'<~Boolean> - success?
|
|
|
|
def delete_volume(volume_id)
|
2010-03-15 22:15:33 -07:00
|
|
|
request(
|
|
|
|
'Action' => 'DeleteVolume',
|
|
|
|
'VolumeId' => volume_id,
|
2010-05-24 14:22:35 -07:00
|
|
|
:idempotent => true,
|
2010-09-08 14:40:02 -07:00
|
|
|
:parser => Fog::Parsers::AWS::Compute::Basic.new
|
2010-03-15 22:15:33 -07:00
|
|
|
)
|
2009-08-15 15:19:07 -07:00
|
|
|
end
|
|
|
|
|
2009-07-13 19:14:59 -07:00
|
|
|
end
|
|
|
|
|
2010-03-16 15:46:21 -07:00
|
|
|
class Mock
|
2009-08-15 15:19:07 -07:00
|
|
|
|
|
|
|
def delete_volume(volume_id)
|
2009-11-20 11:08:08 -08:00
|
|
|
response = Excon::Response.new
|
2010-03-16 15:46:21 -07:00
|
|
|
if volume = @data[:volumes][volume_id]
|
2010-08-17 03:30:01 +08:00
|
|
|
if volume["attachmentSet"].any?
|
|
|
|
attach = volume["attachmentSet"].first
|
2010-09-09 17:50:38 -07:00
|
|
|
raise Fog::AWS::Compute::Error.new("Client.VolumeInUse => Volume #{volume_id} is currently attached to #{attach["instanceId"]}")
|
2010-08-17 03:30:01 +08:00
|
|
|
end
|
2010-03-16 15:46:21 -07:00
|
|
|
@data[:deleted_at][volume_id] = Time.now
|
2009-08-15 15:19:07 -07:00
|
|
|
volume['status'] = 'deleting'
|
|
|
|
response.status = 200
|
|
|
|
response.body = {
|
|
|
|
'requestId' => Fog::AWS::Mock.request_id,
|
2009-08-20 19:25:52 -07:00
|
|
|
'return' => true
|
2009-08-15 15:19:07 -07:00
|
|
|
}
|
2010-05-25 22:26:20 -07:00
|
|
|
response
|
2009-08-15 15:19:07 -07:00
|
|
|
else
|
2010-09-09 17:50:38 -07:00
|
|
|
raise Fog::AWS::Compute::NotFound.new("The volume '#{volume_id}' does not exist.")
|
2009-08-15 15:19:07 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2009-07-13 19:14:59 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|