Sha256: 7b3b8351b1228d624986c93cccf6d47c539a02f1c0ca321e87adb96237d7b518

Contents?: true

Size: 1.75 KB

Versions: 21

Compression:

Stored size: 1.75 KB

Contents

module Fog
  module Network
    class OpenStack
      class Real
        def create_subnet(network_id, cidr, ip_version, options = {})
          data = {
            'subnet' => {
              'network_id' => network_id,
              'cidr'       => cidr,
              'ip_version' => ip_version,
            }
          }

          vanilla_options = [:name, :gateway_ip, :allocation_pools,
                             :dns_nameservers, :host_routes, :enable_dhcp,
                             :tenant_id]
          vanilla_options.reject{ |o| options[o].nil? }.each do |key|
            data['subnet'][key] = options[key]
          end

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

      class Mock
        def create_subnet(network_id, cidr, ip_version, options = {})
          response = Excon::Response.new
          response.status = 201
          data = {
            'id'               => Fog::Mock.random_numbers(6).to_s,
            'name'             => options[:name],
            'network_id'       => network_id,
            'cidr'             => cidr,
            'ip_version'       => ip_version,
            'gateway_ip'       => options[:gateway_ip],
            'allocation_pools' => options[:allocation_pools],
            'dns_nameservers'  => options[:dns_nameservers],
            'host_routes'      => options[:host_routes],
            'enable_dhcp'      => options[:enable_dhcp],
            'tenant_id'        => options[:tenant_id],
          }
          self.data[:subnets][data['id']] = data
          response.body = { 'subnet' => data }
          response
        end
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 4 rubygems

Version Path
fog-1.31.0 lib/fog/openstack/requests/network/create_subnet.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/openstack/requests/network/create_subnet.rb
fog-1.30.0 lib/fog/openstack/requests/network/create_subnet.rb
fog-1.29.0 lib/fog/openstack/requests/network/create_subnet.rb
fog-1.28.0 lib/fog/openstack/requests/network/create_subnet.rb
fog-1.27.0 lib/fog/openstack/requests/network/create_subnet.rb
fog-1.26.0 lib/fog/openstack/requests/network/create_subnet.rb
fog-1.25.0 lib/fog/openstack/requests/network/create_subnet.rb
nsidc-fog-1.24.1 lib/fog/openstack/requests/network/create_subnet.rb
fog-1.24.0 lib/fog/openstack/requests/network/create_subnet.rb
ns-fog-1.22.11 lib/fog/openstack/requests/network/create_subnet.rb
ns-fog-1.22.10 lib/fog/openstack/requests/network/create_subnet.rb
ns-fog-1.22.9 lib/fog/openstack/requests/network/create_subnet.rb
ns-fog-1.22.8 lib/fog/openstack/requests/network/create_subnet.rb
ns-fog-1.22.7 lib/fog/openstack/requests/network/create_subnet.rb
ns-fog-1.22.6 lib/fog/openstack/requests/network/create_subnet.rb
fog-1.23.0 lib/fog/openstack/requests/network/create_subnet.rb
ns-fog-1.22.4 lib/fog/openstack/requests/network/create_subnet.rb
ns-fog-1.22.3 lib/fog/openstack/requests/network/create_subnet.rb
ns-fog-1.22.2 lib/fog/openstack/requests/network/create_subnet.rb