2010-03-19 18:29:42 -07:00
|
|
|
module Fog
|
|
|
|
module Rackspace
|
2010-09-08 13:50:23 -07:00
|
|
|
class Compute
|
2010-03-19 18:29:42 -07:00
|
|
|
class Real
|
2009-10-15 22:24:42 -07:00
|
|
|
|
|
|
|
# Delete an image
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * image_id<~Integer> - Id of image to delete
|
|
|
|
#
|
|
|
|
def delete_image(image_id)
|
|
|
|
request(
|
|
|
|
:expects => 204,
|
|
|
|
:method => 'DELETE',
|
|
|
|
:path => "images/#{image_id}"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2010-03-19 18:29:42 -07:00
|
|
|
class Mock
|
2009-10-15 22:24:42 -07:00
|
|
|
|
2009-11-20 12:46:44 -08:00
|
|
|
def delete_image(image_id)
|
|
|
|
response = Excon::Response.new
|
2010-10-13 13:20:18 -07:00
|
|
|
if image = list_images_detail.body['images'].detect {|_| _['id'] == image_id}
|
2009-11-20 12:46:44 -08:00
|
|
|
if image['status'] == 'SAVING'
|
|
|
|
response.status = 409
|
|
|
|
raise(Excon::Errors.status_error({:expects => 202}, response))
|
|
|
|
else
|
2010-03-19 18:29:42 -07:00
|
|
|
@data[:last_modified][:images].delete(image_id)
|
|
|
|
@data[:images].delete(image_id)
|
2009-11-20 12:46:44 -08:00
|
|
|
response.status = 202
|
|
|
|
end
|
2010-05-31 11:05:14 -05:00
|
|
|
response
|
2009-11-20 12:46:44 -08:00
|
|
|
else
|
|
|
|
response.status = 400
|
|
|
|
raise(Excon::Errors.status_error({:expects => 202}, response))
|
|
|
|
end
|
2010-05-31 11:05:14 -05:00
|
|
|
|
2009-10-15 22:24:42 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|