2010-09-07 19:26:01 -04:00
|
|
|
module Fog
|
2011-06-16 19:28:54 -04:00
|
|
|
module Compute
|
|
|
|
class Bluebox
|
2010-09-07 19:26:01 -04:00
|
|
|
class Real
|
|
|
|
|
|
|
|
# Create a new block
|
|
|
|
#
|
|
|
|
# ==== Parameters
|
2012-08-17 16:41:51 -04:00
|
|
|
# * product_id<~String> - ID of product to create block with
|
|
|
|
# * template_id<~String> - ID of template to create block with
|
|
|
|
# * location_id<~String> - ID of location to create block in
|
2010-09-07 19:26:01 -04:00
|
|
|
# * options<~Hash>:
|
|
|
|
# * password<~String> - Password for block
|
|
|
|
# or
|
|
|
|
# * ssh_key<~String> - ssh public key
|
|
|
|
# * username<~String> - optional, defaults to deploy
|
|
|
|
#
|
|
|
|
# ==== Returns
|
|
|
|
# * response<~Excon::Response>:
|
|
|
|
# * body<~Hash>:
|
2012-02-12 03:02:52 -05:00
|
|
|
def create_block(product_id, template_id, location_id, options = {})
|
2012-08-17 16:41:51 -04:00
|
|
|
|
|
|
|
unless options.has_key?(:password) || options.has_key?(:ssh_key)
|
|
|
|
raise ArgumentError, 'Either password or ssh_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('&')
|
|
|
|
|
2010-09-07 19:26:01 -04:00
|
|
|
request(
|
|
|
|
:expects => 200,
|
|
|
|
:method => 'POST',
|
|
|
|
:path => '/api/blocks.json',
|
2012-08-17 16:41:51 -04:00
|
|
|
:query => query,
|
|
|
|
:body => URI.encode(body)
|
2010-09-07 19:26:01 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|