Sha256: f2bd00e946690d72d8621ec649598ba1e13bbe65fc6229eb299caafa108be373

Contents?: true

Size: 1.3 KB

Versions: 5

Compression:

Stored size: 1.3 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
          }

          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

5 entries across 5 versions & 4 rubygems

Version Path
fog-nirvanix-1.8.2 lib/fog/bluebox/requests/compute/create_block.rb
fog-nirvanix-1.8.1 lib/fog/bluebox/requests/compute/create_block.rb
ey-vendored-backup-3.0.27 vendor/gems/fog/lib/fog/bluebox/requests/compute/create_block.rb
fog-sgonyea-1.8.1 lib/fog/bluebox/requests/compute/create_block.rb
fog-1.8.0 lib/fog/bluebox/requests/compute/create_block.rb