Sha256: 672fee8a9b997a6355ea34c300a18c33951f245ef156ba7a17e9b70fc98b13e2

Contents?: true

Size: 1.53 KB

Versions: 29

Compression:

Stored size: 1.53 KB

Contents

module Fog
  module Compute
    class HPV2
      class Real
        # Acquires a floating IP address
        #
        # Note: This method will proxy the call to the Network (Quantum) service,
        # to allocate an floating IP address from the first network available.
        # If the network is not routable, it will throw an exception.
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        #   * 'floating_ip'<~Hash> -
        #     * 'id'<~String> - UUId of the Floating IP 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'
          )
        end
      end

      class Mock
        def allocate_address
          response = Excon::Response.new
          response.status = 200
          data = {
            'instance_id' => Fog::HP::Mock.uuid.to_s,
            'ip'          => Fog::HP::Mock.ip_address,
            'fixed_ip'    => Fog::HP::Mock.ip_address,
            'id'          => Fog::HP::Mock.uuid.to_s
          }
          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_v2/allocate_address.rb
fog-1.36.0 lib/fog/hp/requests/compute_v2/allocate_address.rb
fog-1.35.0 lib/fog/hp/requests/compute_v2/allocate_address.rb
fog-2.0.0.pre.0 lib/fog/hp/requests/compute_v2/allocate_address.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/hp/requests/compute_v2/allocate_address.rb
fog-1.34.0 lib/fog/hp/requests/compute_v2/allocate_address.rb
fog-1.33.0 lib/fog/hp/requests/compute_v2/allocate_address.rb
fog-1.32.0 lib/fog/hp/requests/compute_v2/allocate_address.rb
fog-1.31.0 lib/fog/hp/requests/compute_v2/allocate_address.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/hp/requests/compute_v2/allocate_address.rb
fog-1.30.0 lib/fog/hp/requests/compute_v2/allocate_address.rb
fog-1.29.0 lib/fog/hp/requests/compute_v2/allocate_address.rb
fog-1.28.0 lib/fog/hp/requests/compute_v2/allocate_address.rb
fog-1.27.0 lib/fog/hp/requests/compute_v2/allocate_address.rb
fog-1.26.0 lib/fog/hp/requests/compute_v2/allocate_address.rb
fog-1.25.0 lib/fog/hp/requests/compute_v2/allocate_address.rb
nsidc-fog-1.24.1 lib/fog/hp/requests/compute_v2/allocate_address.rb
fog-1.24.0 lib/fog/hp/requests/compute_v2/allocate_address.rb
ns-fog-1.22.11 lib/fog/hp/requests/compute_v2/allocate_address.rb
ns-fog-1.22.10 lib/fog/hp/requests/compute_v2/allocate_address.rb