2010-03-19 21:29:42 -04:00
|
|
|
module Fog
|
|
|
|
module Rackspace
|
|
|
|
module Servers
|
|
|
|
class Real
|
2009-10-14 01:36:35 -04:00
|
|
|
|
|
|
|
# Delete an existing server
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * id<~Integer> - Id of server to delete
|
|
|
|
#
|
2009-11-09 22:36:27 -05:00
|
|
|
def delete_server(server_id)
|
2009-10-14 01:36:35 -04:00
|
|
|
request(
|
|
|
|
:expects => 202,
|
|
|
|
:method => 'DELETE',
|
2009-11-09 22:36:27 -05:00
|
|
|
:path => "servers/#{server_id}"
|
2009-10-14 01:36:35 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2010-03-19 21:29:42 -04:00
|
|
|
class Mock
|
2009-10-14 01:36:35 -04:00
|
|
|
|
2009-11-09 22:36:27 -05:00
|
|
|
def delete_server(server_id)
|
2009-11-20 14:08:08 -05:00
|
|
|
response = Excon::Response.new
|
2009-11-10 01:53:04 -05:00
|
|
|
if server = list_servers_detail.body['servers'].detect { |server| server['id'] == server_id }
|
|
|
|
if server['status'] == 'BUILD'
|
2009-11-08 15:16:52 -05:00
|
|
|
response.status = 409
|
2009-11-20 15:46:44 -05:00
|
|
|
raise(Excon::Errors.status_error({:expects => 202}, response))
|
2009-11-08 15:16:52 -05:00
|
|
|
else
|
2010-03-19 21:29:42 -04:00
|
|
|
@data[:last_modified][:servers].delete(server_id)
|
|
|
|
@data[:servers].delete(server_id)
|
2009-11-08 15:16:52 -05:00
|
|
|
response.status = 202
|
|
|
|
end
|
2010-05-31 11:37:26 -04:00
|
|
|
response
|
2009-11-08 01:29:25 -05:00
|
|
|
else
|
2010-05-31 11:37:26 -04:00
|
|
|
raise Fog::Rackspace::Servers::NotFound
|
2009-11-08 01:29:25 -05:00
|
|
|
end
|
2009-10-14 01:36:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|