1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[bbg] create_block: allow specifying username, remove name param

This commit is contained in:
geemus 2010-06-03 22:20:31 -07:00
parent a5907a9fdc
commit 93ea9de278
5 changed files with 12 additions and 10 deletions

View file

@ -22,7 +22,7 @@ module Fog
attribute :template
# Not reported by the API, but used at create time
attr_accessor :name, :password, :ssh_key
attr_accessor :password, :ssh_key, :user
def destroy
requires :id
@ -59,7 +59,10 @@ module Fog
elsif @password
{'password' => @password}
end
data = connection.create_block(@flavor_id, @image_id, @name, options)
if @user
options['user'] = @user
end
data = connection.create_block(@flavor_id, @image_id, options)
merge_attributes(data.body)
true
end

View file

@ -7,19 +7,18 @@ module Fog
# ==== Parameters
# * product_id<~Integer> - Id of product to create block with
# * template_id<~Integer> - Id of template to create block with
# * name<~String> - Name of block
# * 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>:
# TODO
def create_block(product_id, template_id, name, options = {})
def create_block(product_id, template_id, options = {})
data = {
'name' => name,
'product' => product_id,
'template' => template_id
}.merge!(options)

View file

@ -8,7 +8,7 @@ describe 'Fog::Bluebox::Server' do
subject {
@flavor_id = '94fd37a7-2606-47f7-84d5-9000deda52ae' # Block 1GB Virtual Server
@image_id = 'a00baa8f-b5d0-4815-8238-b471c4c4bf72' # Ubuntu 9.10 64bit
@server = @servers.new(:flavor_id => @flavor_id, :image_id => @image_id, :name => Time.now.to_i.to_s, :password => "chunkybacon")
@server = @servers.new(:flavor_id => @flavor_id, :image_id => @image_id, :password => "chunkybacon")
}
before(:each) do

View file

@ -9,7 +9,7 @@ describe 'Fog::Bluebox::Servers' do
subject {
@flavor_id = '94fd37a7-2606-47f7-84d5-9000deda52ae' # Block 1GB Virtual Server
@image_id = 'a00baa8f-b5d0-4815-8238-b471c4c4bf72' # Ubuntu 9.10 64bit
@server = @servers.new(:flavor_id => @flavor_id, :image_id => @image_id, :name => Time.now.to_i.to_s, :password => "chunkybacon")
@server = @servers.new(:flavor_id => @flavor_id, :image_id => @image_id, :password => "chunkybacon")
@server
}

View file

@ -17,12 +17,12 @@ Shindo.tests('Bluebox | block requests', ['bluebox']) do
@product_id = '94fd37a7-2606-47f7-84d5-9000deda52ae' # 1 GB
@template_id = 'a00baa8f-b5d0-4815-8238-b471c4c4bf72' # Ubuntu 9.10 64bit
@password = 'R8p6ikXOfCxoKy'
@password = 'chunkybacon'
@block_id = nil
tests("create_block('#{@product_id}', '#{@template_id}', 'fog_block', 'password' => '#{@password}')").formats(@block_format) do
data = Bluebox[:blocks].create_block(@product_id, @template_id, 'fog_block', 'password' => @password).body
tests("create_block('#{@product_id}', '#{@template_id}', 'password' => '#{@password}')").formats(@block_format) do
data = Bluebox[:blocks].create_block(@product_id, @template_id, 'password' => @password).body
@block_id = data['id']
data
end