Sha256: 312c8e3e9f657b686987146c77a679c2ed905288c1e521d2416e32ee07abb519

Contents?: true

Size: 1.38 KB

Versions: 39

Compression:

Stored size: 1.38 KB

Contents

module Fog
  module Compute
    class Bluebox
      class Real
        # Create a new block
        #
        # ==== Parameters
        # * product_id<~String>   - ID of block product (size)
        # * template_id<~String>  - ID of block OS/build template
        # * location_id<~String>  - ID of deployment location
        # * options<~Hash>:
        #     * password<~String>   - Password for block
        #   or
        #     * ssh_public_key<~String> - SSH public key
        #     * username<~String>   - Defaults to deploy
        #
        # ==== Returns
        # * response<~Excon::Response>:
        #   * body<~Hash>:
        def create_block(product_id, template_id, location_id, options = {})
          unless options.key?('password') || options.key?('ssh_public_key')
            raise ArgumentError, 'Either password or public_key must be supplied'
          end

          query = {
            'product'  => product_id,
            'template' => template_id,
            'location' => location_id
          }

          query['ipv6_only'] = options.delete('ipv6_only') if options['ipv6_only']

          request(
            :expects  => 200,
            :method   => 'POST',
            :path     => '/api/blocks.json',
            :query    => query,
            :body     => options.map {|k,v| "#{CGI.escape(k)}=#{CGI.escape(v)}"}.join('&')
          )
        end
      end
    end
  end
end

Version data entries

39 entries across 37 versions & 5 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-1.42.1/lib/fog/bluebox/requests/compute/create_block.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-1.42.1/lib/fog/bluebox/requests/compute/create_block.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-1.42.1/lib/fog/bluebox/requests/compute/create_block.rb
fog-1.42.1 lib/fog/bluebox/requests/compute/create_block.rb
fog-2.0.0 lib/fog/bluebox/requests/compute/create_block.rb
fog-1.42.0 lib/fog/bluebox/requests/compute/create_block.rb
fog-1.41.0 lib/fog/bluebox/requests/compute/create_block.rb
fog-1.40.0 lib/fog/bluebox/requests/compute/create_block.rb
fog-1.39.0 lib/fog/bluebox/requests/compute/create_block.rb
fog-1.38.0 lib/fog/bluebox/requests/compute/create_block.rb
fog-1.37.0 lib/fog/bluebox/requests/compute/create_block.rb
fog-1.36.0 lib/fog/bluebox/requests/compute/create_block.rb
fog-1.35.0 lib/fog/bluebox/requests/compute/create_block.rb
fog-2.0.0.pre.0 lib/fog/bluebox/requests/compute/create_block.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/bluebox/requests/compute/create_block.rb
fog-1.34.0 lib/fog/bluebox/requests/compute/create_block.rb
fog-1.33.0 lib/fog/bluebox/requests/compute/create_block.rb
fog-1.32.0 lib/fog/bluebox/requests/compute/create_block.rb
fog-1.31.0 lib/fog/bluebox/requests/compute/create_block.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/bluebox/requests/compute/create_block.rb