Sha256: 60c7a412a062c18b791e33b95ff9e2351babda891746391900627885a0b6dd86

Contents?: true

Size: 1.34 KB

Versions: 39

Compression:

Stored size: 1.34 KB

Contents

module Fog
  module Network
    class OpenStack

      class Real
        def create_floating_ip(floating_network_id, options = {})
          data = {
            'floatingip' => {
              'floating_network_id' => floating_network_id
            }
          }

          vanilla_options = [:port_id, :tenant_id, :fixed_ip_address ]
          vanilla_options.reject{ |o| options[o].nil? }.each do |key|
            data['floatingip'][key] = options[key]
          end

          request(
            :body     => Fog::JSON.encode(data),
            :expects  => [201],
            :method   => 'POST',
            :path     => 'floatingips'
          )
        end
      end

      class Mock
        def create_floating_ip(floating_network_id, options = {})
          response = Excon::Response.new
          response.status = 201
          data = {
            'id'                  => floating_network_id,
            'floating_network_id' => floating_network_id,
            'port_id'             => options[:port_id],
            'tenant_id'           => options[:tenant_id],
            'fixed_ip_address'    => options[:fixed_ip_address],
            'router_id'           => nil,
          }
          self.data[:floating_ips][data['id']] = data
          response.body = { 'floatingip' => data }
          response
        end
      end

    end
  end
end

Version data entries

39 entries across 39 versions & 2 rubygems

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