Sha256: 48ba5cad39e61f2e58d380f184981fe672d73e6df8009a8b8a9b153b0b42dba2

Contents?: true

Size: 1.11 KB

Versions: 8

Compression:

Stored size: 1.11 KB

Contents

module Fog
  module Rackspace
    class Compute
      class Real

        # List all server addresses
        #
        # ==== Parameters
        # * server_id<~Integer> - Id of server to list addresses for
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        #   * 'addresses'<~Array>:
        #     * 'public'<~Array> - Public ip addresses
        #     * 'private'<~Array> - Private ip addresses
        def list_addresses(server_id)
          request(
            :expects  => [200, 203],
            :method   => 'GET',
            :path     => "servers/#{server_id}/ips.json"
          )
        end

      end

      class Mock

        def list_addresses(server_id)
          response = Excon::Response.new
          if server = list_servers_detail.body['servers'].detect { |server| server['id'] == server_id }
            response.status = [200, 203][rand(1)]
            response.body = { 'addresses' => server['addresses'] }
            response
          else
            raise Fog::Rackspace::Compute::NotFound
          end
        end

      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fog-0.3.7 lib/fog/rackspace/requests/compute/list_addresses.rb
fog-0.3.6 lib/fog/rackspace/requests/compute/list_addresses.rb
fog-0.3.5 lib/fog/rackspace/requests/compute/list_addresses.rb
fog-0.3.4 lib/fog/rackspace/requests/compute/list_addresses.rb
fog-0.3.3 lib/fog/rackspace/requests/compute/list_addresses.rb
fog-0.3.2 lib/fog/rackspace/requests/compute/list_addresses.rb
fog-0.3.1 lib/fog/rackspace/requests/compute/list_addresses.rb
fog-0.3.0 lib/fog/rackspace/requests/compute/list_addresses.rb