Sha256: 479f39ba5c11938725e774e48b328728e3ad2e3f865f9347d5d19b57655b59bc

Contents?: true

Size: 1.31 KB

Versions: 29

Compression:

Stored size: 1.31 KB

Contents

module Fog
  module Compute
    class HP
      class Real
        # Acquires a floating IP address
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        #     * 'floating_ip'<~Hash> -
        #       * 'id'<~Integer> - Id of the address
        #       * 'ip'<~String> - Floating IP of the address
        #       * 'instance_id'<~String> - Id of the associated server instance
        #       * 'fixed_ip'<~String> - Fixed IP of the address
        def allocate_address
          request(
            :body     => nil,
            :expects  => 200,
            :method   => 'POST',
            :path     => 'os-floating-ips.json'
          )
        end
      end

      class Mock
        def allocate_address
          response = Excon::Response.new
          response.status = 200
          data = {
            'instance_id' => Fog::HP::Mock.instance_id.to_i,
            'ip'          => Fog::HP::Mock.ip_address,
            'fixed_ip'    => Fog::HP::Mock.ip_address,
            'id'          => Fog::Mock.random_numbers(3).to_i
          }
          self.data[:last_modified][:addresses][data['id']] = Time.now
          self.data[:addresses][data['id']] = data

          response.body = { 'floating_ip' => data }
          response
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 4 rubygems

Version Path
fog-1.37.0 lib/fog/hp/requests/compute/allocate_address.rb
fog-1.36.0 lib/fog/hp/requests/compute/allocate_address.rb
fog-1.35.0 lib/fog/hp/requests/compute/allocate_address.rb
fog-2.0.0.pre.0 lib/fog/hp/requests/compute/allocate_address.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/hp/requests/compute/allocate_address.rb
fog-1.34.0 lib/fog/hp/requests/compute/allocate_address.rb
fog-1.33.0 lib/fog/hp/requests/compute/allocate_address.rb
fog-1.32.0 lib/fog/hp/requests/compute/allocate_address.rb
fog-1.31.0 lib/fog/hp/requests/compute/allocate_address.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/hp/requests/compute/allocate_address.rb
fog-1.30.0 lib/fog/hp/requests/compute/allocate_address.rb
fog-1.29.0 lib/fog/hp/requests/compute/allocate_address.rb
fog-1.28.0 lib/fog/hp/requests/compute/allocate_address.rb
fog-1.27.0 lib/fog/hp/requests/compute/allocate_address.rb
fog-1.26.0 lib/fog/hp/requests/compute/allocate_address.rb
fog-1.25.0 lib/fog/hp/requests/compute/allocate_address.rb
nsidc-fog-1.24.1 lib/fog/hp/requests/compute/allocate_address.rb
fog-1.24.0 lib/fog/hp/requests/compute/allocate_address.rb
ns-fog-1.22.11 lib/fog/hp/requests/compute/allocate_address.rb
ns-fog-1.22.10 lib/fog/hp/requests/compute/allocate_address.rb