2010-03-19 21:29:42 -04:00
|
|
|
module Fog
|
|
|
|
module Rackspace
|
|
|
|
module Servers
|
|
|
|
class Real
|
2009-10-15 01:02:24 -04:00
|
|
|
|
2009-10-18 21:11:19 -04:00
|
|
|
# Get details about a server
|
2009-10-15 01:02:24 -04:00
|
|
|
#
|
2009-11-02 02:34:21 -05:00
|
|
|
# ==== Parameters
|
|
|
|
# * server_id<~Integer> - Id of server to get details for
|
|
|
|
#
|
2009-10-15 01:02:24 -04:00
|
|
|
# ==== Returns
|
2009-11-02 21:48:49 -05:00
|
|
|
# * response<~Excon::Response>:
|
2009-10-15 01:02:24 -04:00
|
|
|
# * body<~Hash>:
|
2009-10-18 21:11:19 -04:00
|
|
|
# * 'server'<~Hash>:
|
2009-10-15 01:02:24 -04:00
|
|
|
# * 'addresses'<~Hash>:
|
|
|
|
# * 'public'<~Array> - public address strings
|
|
|
|
# * 'private'<~Array> - private address strings
|
2009-10-18 21:11:19 -04:00
|
|
|
# * 'flavorId'<~Integer> - Id of servers current flavor
|
|
|
|
# * 'hostId'<~String>
|
|
|
|
# * 'id'<~Integer> - Id of server
|
|
|
|
# * 'imageId'<~Integer> - Id of image used to boot server
|
2009-10-15 01:02:24 -04:00
|
|
|
# * 'metadata'<~Hash> - metadata
|
2009-10-18 21:11:19 -04:00
|
|
|
# * 'name<~String> - Name of server
|
|
|
|
# * 'progress'<~Integer> - Progress through current status
|
|
|
|
# * 'status'<~String> - Current server status
|
2009-11-02 02:34:21 -05:00
|
|
|
def get_server_details(server_id)
|
2009-10-15 01:02:24 -04:00
|
|
|
request(
|
2009-11-10 12:37:47 -05:00
|
|
|
:expects => [200, 203],
|
2009-10-15 01:02:24 -04:00
|
|
|
:method => 'GET',
|
2009-11-02 02:34:21 -05:00
|
|
|
:path => "servers/#{server_id}.json"
|
2009-10-15 01:02:24 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2010-03-19 21:29:42 -04:00
|
|
|
class Mock
|
2009-10-15 01:02:24 -04:00
|
|
|
|
2009-11-10 12:37:47 -05:00
|
|
|
def get_server_details(server_id)
|
2009-11-20 14:08:08 -05:00
|
|
|
response = Excon::Response.new
|
2009-11-10 12:37:47 -05:00
|
|
|
if server = list_servers_detail.body['servers'].detect { |server| server['id'] == server_id }
|
|
|
|
response.status = [200, 203][rand(1)]
|
|
|
|
response.body = { 'server' => server }
|
|
|
|
else
|
|
|
|
response.status = 404
|
2009-11-20 14:08:08 -05:00
|
|
|
raise(Excon::Errors.status_error({:expects => 202}, response))
|
2009-11-10 12:37:47 -05:00
|
|
|
end
|
|
|
|
response
|
2009-10-15 01:02:24 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|