Parent

Class/Module Index [+]

Quicksearch

Fog::Compute::Bluebox::Real

Public Class Methods

new(options={}) click to toggle source
# File lib/fog/bluebox/compute.rb, line 64
def initialize(options={})
  @bluebox_api_key      = options[:bluebox_api_key]
  @bluebox_customer_id  = options[:bluebox_customer_id]
  @connection_options   = options[:connection_options] || {}
  @host       = options[:bluebox_host]    || "boxpanel.bluebox.net"
  @persistent = options[:persistent]      || false
  @port       = options[:bluebox_port]    || 443
  @scheme     = options[:bluebox_scheme]  || 'https'
  @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end

Public Instance Methods

create_block(product_id, template_id, location_id, options = {}) click to toggle source

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>:

# File lib/fog/bluebox/requests/compute/create_block.rb, line 21
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
create_template(block_id, options={}) click to toggle source

Create a template from block

Parameters

  • block_id<~Integer> - Id of block to create template from

Returns

  • response<~Excon::Response>:

    • body<~Array>:

TODO

# File lib/fog/bluebox/requests/compute/create_template.rb, line 15
def create_template(block_id, options={})
  request(
    :expects  => 202,
    :method   => 'POST',
    :path     => "api/block_templates.json",
    :query    => {'id' => block_id}.merge!(options)
  )
end
destroy_block(block_id) click to toggle source

Destroy a block

Parameters

  • block_id<~Integer> - Id of block to destroy

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

TODO

# File lib/fog/bluebox/requests/compute/destroy_block.rb, line 15
def destroy_block(block_id)
  request(
    :expects  => 200,
    :method   => 'DELETE',
    :path     => "api/blocks/#{block_id}.json"
  )
end
destroy_template(id) click to toggle source

Create a template from block

Parameters

  • id<~Integer> - Id of image to destroy

Returns

  • response<~Excon::Response>:

    • body<~Array>:

TODO

# File lib/fog/bluebox/requests/compute/destroy_template.rb, line 15
def destroy_template(id)
  request(
    :expects  => 200,
    :method   => 'DELETE',
    :path     => "api/block_templates/#{id}.json"
  )
end
get_block(block_id) click to toggle source

Get details of a block.

Parameters

  • block_id<~Integer> - Id of block to lookup

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

TODO

# File lib/fog/bluebox/requests/compute/get_block.rb, line 15
def get_block(block_id)
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "api/blocks/#{block_id}.json"
  )
end
get_blocks() click to toggle source

Get list of blocks

Returns

  • response<~Excon::Response>:

    • body<~Array>:

      • 'ips'<~Array> - Ip addresses for the block

      • 'id'<~String> - Id of the block

      • 'storage'<~Integer> - Disk space quota for the block

      • 'memory'<~Integer> - RAM quota for the block

      • 'cpu'<~Float> - The fractional CPU quota for this block

      • 'hostname'<~String> - The hostname for the block

# File lib/fog/bluebox/requests/compute/get_blocks.rb, line 17
def get_blocks
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => 'api/blocks.json'
  )
end
get_location(location_id) click to toggle source

Get details of a location

Parameters

  • location_id<~Integer> - Id of location to lookup

Returns

  • response<~Excon::Response>:

    • body<~Array>:

TODO

# File lib/fog/bluebox/requests/compute/get_location.rb, line 15
def get_location(location_id)
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "api/locations/#{location_id}.json"
  )
end
get_locations() click to toggle source

Get list of locations

Returns

  • response<~Excon::Response>:

    • body<~Array>:

      • 'id'<~String> - UUID of the location

      • 'description'<~String> - Description of the location

# File lib/fog/bluebox/requests/compute/get_locations.rb, line 13
def get_locations
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => 'api/locations.json'
  )
end
get_product(product_id) click to toggle source

Get details of a product

Parameters

  • product_id<~Integer> - Id of flavor to lookup

Returns

  • response<~Excon::Response>:

    • body<~Array>:

TODO

# File lib/fog/bluebox/requests/compute/get_product.rb, line 15
def get_product(product_id)
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "api/block_products/#{product_id}.json"
  )
end
get_products() click to toggle source

Get list of products

Returns

  • response<~Excon::Response>:

    • body<~Array>:

      • 'id'<~String> - UUID of the product

      • 'description'<~String> - Description of the product

      • 'cost'<~Decimal> - Hourly cost of the product

# File lib/fog/bluebox/requests/compute/get_products.rb, line 14
def get_products
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => 'api/block_products.json'
  )
end
get_template(template_id) click to toggle source

Get details of a template

Parameters

  • template_id<~Integer> - Id of template to lookup

Returns

  • response<~Excon::Response>:

    • body<~Array>:

TODO

# File lib/fog/bluebox/requests/compute/get_template.rb, line 15
def get_template(template_id)
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "api/block_templates/#{template_id}.json"
  )
end
get_templates() click to toggle source

Get list of OS templates

Returns

  • response<~Excon::Response>:

    • body<~Array>:

      • 'id'<~String> - UUID of the image

      • 'description'<~String> - Description of the image

      • 'public'<~Boolean> - Public / Private image

      • 'created'<~Datetime> - Timestamp of when the image was created

# File lib/fog/bluebox/requests/compute/get_templates.rb, line 15
def get_templates
  request(
    :expects  => 200,
    :method   => 'GET',
    :path     => 'api/block_templates.json'
  )
end
reboot_block(block_id, type = 'SOFT') click to toggle source

Reboot block

Parameters

  • block_id<~String> - Id of block to reboot

  • type<~String> - Type of reboot, must be in ['HARD', 'SOFT']

Returns

  • response<~Excon::Response>:

    • body<~Hash>:

TODO

# File lib/fog/bluebox/requests/compute/reboot_block.rb, line 16
def reboot_block(block_id, type = 'SOFT')
  request(
    :expects  => 200,
    :method   => 'PUT',
    :path     => "api/blocks/#{block_id}/#{'soft_' if type == 'SOFT'}reboot.json"
  )
end
reload() click to toggle source
# File lib/fog/bluebox/compute.rb, line 75
def reload
  @connection.reset
end
request(params) click to toggle source
# File lib/fog/bluebox/compute.rb, line 79
def request(params)
  params[:headers] ||= {}
  params[:headers].merge!({
    'Authorization' => "Basic #{Base64.encode64([@bluebox_customer_id, @bluebox_api_key].join(':')).delete("\r\n")}"
  })

  begin
    response = @connection.request(params.merge!({:host => @host}))
  rescue Excon::Errors::HTTPStatusError => error
    raise case error
    when Excon::Errors::NotFound
      Fog::Compute::Bluebox::NotFound.slurp(error)
    else
      error
    end
  end
  unless response.body.empty?
    response.body = Fog::JSON.decode(response.body)
  end
  response
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.