2009-10-14 01:36:35 -04:00
|
|
|
unless Fog.mocking?
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Rackspace
|
|
|
|
class Servers
|
|
|
|
|
|
|
|
# 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
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Rackspace
|
|
|
|
class Servers
|
|
|
|
|
2009-11-09 22:36:27 -05:00
|
|
|
def delete_server(server_id)
|
2009-11-08 01:29:25 -05:00
|
|
|
response = Fog::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-10 01:53:04 -05:00
|
|
|
raise(Excon::Errors.status_error(202, 409, response))
|
2009-11-08 15:16:52 -05:00
|
|
|
else
|
2009-11-10 14:27:35 -05:00
|
|
|
Fog::Rackspace::Servers.data[:last_modified].delete(server_id)
|
2009-11-10 01:53:04 -05:00
|
|
|
Fog::Rackspace::Servers.data[:servers].delete(server_id)
|
2009-11-08 15:16:52 -05:00
|
|
|
response.status = 202
|
|
|
|
end
|
2009-11-08 01:29:25 -05:00
|
|
|
else
|
|
|
|
response.status = 404
|
2009-11-09 22:36:27 -05:00
|
|
|
raise(Excon::Errors.status_error(202, 404, response))
|
2009-11-08 01:29:25 -05:00
|
|
|
end
|
|
|
|
response
|
2009-10-14 01:36:35 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|