Sha256: 1ed1eaf4d167b30ecdfd352b808bd39c984d666eacf706646b8e6c02d7d3cbcd

Contents?: true

Size: 1.69 KB

Versions: 31

Compression:

Stored size: 1.69 KB

Contents

module Fog
  module Network
    class OpenStack
      class Real
        def update_subnet_pool(subnet_pool_id, options = {})
          data = {'subnetpool' => {}}

          vanilla_options = [:name, :description, :prefixes, :address_scope_id,
                             :min_prefixlen, :max_prefixlen, :default_prefixlen]
          vanilla_options.select { |o| options.key?(o) }.each do |key|
            data['subnetpool'][key] = options[key]
          end

          request(
            :body    => Fog::JSON.encode(data),
            :expects => 200,
            :method  => 'PUT',
            :path    => "subnetpools/#{subnet_pool_id}"
          )
        end
      end

      class Mock
        def update_subnet_pool(subnet_pool_id, options = {})
          subnet_pool = list_subnet_pools.body['subnetpools'].find { |s| s['id'] == subnet_pool_id }
          if subnet_pool
            subnet_pool['name']              = options[:name]
            subnet_pool['description']       = options[:description]
            subnet_pool['prefixes']          = options[:prefixes] || []
            subnet_pool['min_prefixlen']     = options[:min_prefixlen] || 64
            subnet_pool['max_prefixlen']     = options[:max_prefixlen] || 64
            subnet_pool['default_prefixlen'] = options[:default_prefixlen] || 64
            subnet_pool['address_scope_id']  = options[:address_scope_id]
            subnet_pool['updated_at']        = Time.now.to_s
            response = Excon::Response.new
            response.body = {'subnetpool' => subnet_pool}
            response.status = 200
            response
          else
            raise Fog::Network::OpenStack::NotFound
          end
        end
      end
    end
  end
end

Version data entries

31 entries across 29 versions & 3 rubygems

Version Path
fog-openstack-0.1.27 lib/fog/network/openstack/requests/update_subnet_pool.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-openstack-0.1.26/lib/fog/network/openstack/requests/update_subnet_pool.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-openstack-0.1.26/lib/fog/network/openstack/requests/update_subnet_pool.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-openstack-0.1.26/lib/fog/network/openstack/requests/update_subnet_pool.rb
fog-openstack-0.1.26 lib/fog/network/openstack/requests/update_subnet_pool.rb
fog-openstack-0.1.25 lib/fog/network/openstack/requests/update_subnet_pool.rb
fog-openstack-0.1.24 lib/fog/network/openstack/requests/update_subnet_pool.rb
fog-openstack-0.1.23 lib/fog/network/openstack/requests/update_subnet_pool.rb
fog-openstack-0.1.22 lib/fog/network/openstack/requests/update_subnet_pool.rb
fog-openstack-0.1.21 lib/fog/network/openstack/requests/update_subnet_pool.rb
fog-openstack-0.1.20 lib/fog/network/openstack/requests/update_subnet_pool.rb