2010-03-19 21:29:42 -04:00
|
|
|
module Fog
|
2011-06-16 19:28:54 -04:00
|
|
|
module Compute
|
|
|
|
class Rackspace
|
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
|
2011-06-16 19:28:54 -04:00
|
|
|
raise Fog::Compute::Rackspace::NotFound
|
2009-11-10 14:27:35 -05:00
|
|
|
end
|
2009-11-02 02:34:21 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|