Sha256: 306760dc562b6492d04c55fb5ddb33071161644280910a130ba336a266982768

Contents?: true

Size: 1.31 KB

Versions: 63

Compression:

Stored size: 1.31 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.has_key?('password') || options.has_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
          }

          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

63 entries across 63 versions & 6 rubygems

Version Path
fog-maestrodev-1.20.0.20140305101839 lib/fog/bluebox/requests/compute/create_block.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/bluebox/requests/compute/create_block.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/bluebox/requests/compute/create_block.rb
fog-1.20.0 lib/fog/bluebox/requests/compute/create_block.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/bluebox/requests/compute/create_block.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/bluebox/requests/compute/create_block.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/bluebox/requests/compute/create_block.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/bluebox/requests/compute/create_block.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/bluebox/requests/compute/create_block.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/bluebox/requests/compute/create_block.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/bluebox/requests/compute/create_block.rb
fog-1.19.0 lib/fog/bluebox/requests/compute/create_block.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/bluebox/requests/compute/create_block.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/bluebox/requests/compute/create_block.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/bluebox/requests/compute/create_block.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/bluebox/requests/compute/create_block.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/bluebox/requests/compute/create_block.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/bluebox/requests/compute/create_block.rb
fog-maestrodev-1.18.0.20131209090811 lib/fog/bluebox/requests/compute/create_block.rb
fog-maestrodev-1.18.0.20131206115947 lib/fog/bluebox/requests/compute/create_block.rb