Sha256: 3843993b49157976cb3f63e2b2cc4a20dfc641be6bf9722073f4df2b3e894b93

Contents?: true

Size: 1.27 KB

Versions: 89

Compression:

Stored size: 1.27 KB

Contents

module Fog
  module Compute
    class Clodo
      class Real

        # Bye new IP-address for specified server
        # ==== Paramaters
        # * server_id<~Integer> - Id of server to bye IP for
        #
        # ==== Returns
        # * response<~Excon::Response>
        #

        def add_ip_address(server_id)
          request(
                  :expects  => [204],
                  :method   => 'PUT',
                  :path     => "servers/#{server_id}/ips"
                  )
        end
      end

      class Mock
        def add_ip_address(server_id)

          raise Excon::Errors::BadRequest.new(
                                              "Invalid image ID"
                                              ) unless server_id > 0

          data = {
            'primary_ip' => false,
            'isp' => false,
            'ip' => "66.6.#{rand(255)}.#{rand(255)}"
          }

          raise Excon::Errors::BadRequest unless self.data[:servers][server_id]

          raise Excon::Errors::BadRequest.new "No addresses" unless self.data[:servers][server_id]['addresses']

          self.data[:servers][server_id]['addresses']['public'] << data

          response = Excon::Response.new
          response.status = 204
          response
        end
      end
    end
  end
end

Version data entries

89 entries across 89 versions & 16 rubygems

Version Path
fog-1.22.0 lib/fog/clodo/requests/compute/add_ip_address.rb
fog-1.21.0 lib/fog/clodo/requests/compute/add_ip_address.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/clodo/requests/compute/add_ip_address.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/clodo/requests/compute/add_ip_address.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/clodo/requests/compute/add_ip_address.rb
fog-1.20.0 lib/fog/clodo/requests/compute/add_ip_address.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/clodo/requests/compute/add_ip_address.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/clodo/requests/compute/add_ip_address.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/clodo/requests/compute/add_ip_address.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/clodo/requests/compute/add_ip_address.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/clodo/requests/compute/add_ip_address.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/clodo/requests/compute/add_ip_address.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/clodo/requests/compute/add_ip_address.rb
fog-1.19.0 lib/fog/clodo/requests/compute/add_ip_address.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/clodo/requests/compute/add_ip_address.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/clodo/requests/compute/add_ip_address.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/clodo/requests/compute/add_ip_address.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/clodo/requests/compute/add_ip_address.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/clodo/requests/compute/add_ip_address.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/clodo/requests/compute/add_ip_address.rb