1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/rackspace/requests/compute/list_addresses.rb

44 lines
1.1 KiB
Ruby
Raw Normal View History

module Fog
module Compute
class Rackspace
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
# * 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
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
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