Sha256: 28f3caebbf5f9a293309b5bb28d7c489fc2e69321ae60077ba10a568e8b7ef1a

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 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
        #     * 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?('public_key')
            raise ArgumentError, 'Either password or public_key must be supplied'
          end

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

          body = URI.encode options.map {|k,v| "#{k}=#{v}"}.join('&')

          request(
            :expects  => 200,
            :method   => 'POST',
            :path     => '/api/blocks.json',
            :query    => query,
            :body     => URI.encode(body)
          )
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
fog-maestrodev-1.7.0.20121114190951 lib/fog/bluebox/requests/compute/create_block.rb
fog-1.7.0 lib/fog/bluebox/requests/compute/create_block.rb