2010-03-19 21:29:42 -04:00
|
|
|
module Fog
|
|
|
|
module Rackspace
|
2010-09-08 16:50:23 -04:00
|
|
|
class Compute
|
2010-03-19 21:29:42 -04:00
|
|
|
class Real
|
2009-11-02 02:34:21 -05:00
|
|
|
|
|
|
|
# List all server addresses
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
|
|
|
# * server_id<~Integer> - Id of server to list addresses for
|
|
|
|
#
|
|
|
|
# ==== Returns
|
2009-11-02 21:48:49 -05:00
|
|
|
# * response<~Excon::Response>:
|
2009-11-02 02:34:21 -05:00
|
|
|
# * body<~Hash>:
|
|
|
|
# * 'addresses'<~Array>:
|
|
|
|
# * 'public'<~Array> - Public ip addresses
|
|
|
|
# * 'private'<~Array> - Private ip addresses
|
2009-11-04 00:46:27 -05:00
|
|
|
def list_addresses(server_id)
|
2009-11-02 02:34:21 -05:00
|
|
|
request(
|
|
|
|
:expects => [200, 203],
|
|
|
|
:method => 'GET',
|
|
|
|
:path => "servers/#{server_id}/ips.json"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2010-03-19 21:29:42 -04:00
|
|
|
class Mock
|
2009-11-02 02:34:21 -05:00
|
|
|
|
2009-11-04 00:46:27 -05:00
|
|
|
def list_addresses(server_id)
|
2009-11-20 14:08:08 -05:00
|
|
|
response = Excon::Response.new
|
2010-10-13 16:20:18 -04:00
|
|
|
if server = list_servers_detail.body['servers'].detect {|_| _['id'] == server_id}
|
2009-11-10 14:27:35 -05:00
|
|
|
response.status = [200, 203][rand(1)]
|
|
|
|
response.body = { 'addresses' => server['addresses'] }
|
2010-05-31 11:53:30 -04:00
|
|
|
response
|
2009-11-10 14:27:35 -05:00
|
|
|
else
|
2010-09-09 20:50:38 -04:00
|
|
|
raise Fog::Rackspace::Compute::NotFound
|
2009-11-10 14:27:35 -05:00
|
|
|
end
|
2009-11-02 02:34:21 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|