Sha256: 4a313c90095a43a4b28b8d8870c86613348a88e06cd46ca9cf9db8c766e20da6

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

module Fog
  module Network
    class OpenStack
      class Real
        def disassociate_floating_ip(floating_ip_id, options = {})
          data = {
            'floatingip' => {
              'port_id'    => nil,
            }
          }

          vanilla_options = [: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  => [200],
            :method   => 'PUT',
            :path     => "floatingips/#{floating_ip_id}"
          )
        end
      end

      class Mock
        def disassociate_floating_ip(floating_ip_id, options = {})
          if data = self.data[:floating_ips][floating_ip_id]
            response = Excon::Response.new
            response.status = 201
            data['port_id'] = nil
            data['fixed_ip_address'] = nil
            response.body = { 'floatingip' => data }
            response
          else
            raise Fog::Network::OpenStack::NotFound
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fog-openstack-0.1.1 lib/fog/openstack/requests/network/disassociate_floating_ip.rb