Skip to content

Commit

Permalink
Add LB options to block creation
Browse files Browse the repository at this point in the history
  • Loading branch information
ggoodale committed Mar 13, 2011
1 parent e2f5c29 commit d01faf7
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .rvmrc
@@ -0,0 +1,4 @@
rvm_install_on_use_flag=1
rvm_archflags="-arch x86_64"
rvm 1.9.2@fog

1 change: 1 addition & 0 deletions lib/fog/compute/models/bluebox/server.rb
Expand Up @@ -20,6 +20,7 @@ class Server < Fog::Model
attribute :status
attribute :storage
attribute :template
attribute :lb_applications, :type => :array # The Load Balanced Application IDs for this block.

attr_accessor :password
attr_writer :private_key, :private_key_path, :public_key, :public_key_path, :username
Expand Down
2 changes: 1 addition & 1 deletion lib/fog/compute/requests/bluebox/create_block.rb
Expand Up @@ -23,7 +23,7 @@ def create_block(product_id, template_id, options = {})
:expects => 200,
:method => 'POST',
:path => '/api/blocks.json',
:query => {'product' => product_id, 'template' => template_id}.merge!(options)
:query => query = {'product' => product_id, 'template' => template_id}.merge!(options)
)
end

Expand Down
44 changes: 31 additions & 13 deletions tests/compute/requests/bluebox/block_tests.rb
@@ -1,25 +1,30 @@
Shindo.tests('Bluebox::Compute | block requests', ['bluebox']) do

@block_format = {
'cpu' => Float,
'description' => String,
'hostname' => String,
'id' => String,
'ips' => [{'address' => String}],
'memory' => Integer,
'product' => Bluebox::Compute::Formats::PRODUCT,
'status' => String,
'storage' => Integer,
'template' => String
'cpu' => Float,
'description' => String,
'hostname' => String,
'id' => String,
'ips' => [{'address' => String}],
'memory' => Integer,
'product' => Bluebox::Compute::Formats::PRODUCT,
'status' => String,
'storage' => Integer,
'template' => String,
'lb_applications' => Array,
'lb_options' => {'weight' => Integer, 'port' => Integer, 'backup' => String}
}

tests('success') do

@product_id = '94fd37a7-2606-47f7-84d5-9000deda52ae' # 1 GB
@template_id = 'a00baa8f-b5d0-4815-8238-b471c4c4bf72' # Ubuntu 9.10 64bit
@password = 'chunkybacon'
@product_id = '94fd37a7-2606-47f7-84d5-9000deda52ae' # 1 GB
@template_id = 'a00baa8f-b5d0-4815-8238-b471c4c4bf72' # Ubuntu 9.10 64bit
@password = 'chunkybacon'
@lb_applications = []
@lb_options = {'weight' => 1, 'port' => 80, 'backup' => 'true'}

@block_id = nil
@lb_block_id = nil

tests("create_block('#{@product_id}', '#{@template_id}', 'password' => '#{@password}')").formats(@block_format) do
pending if Fog.mocking?
Expand All @@ -28,6 +33,14 @@
data
end

tests("create_block('#{@product_id}', '#{@template_id}', 'password' => '#{@password}', 'lb_applications' => '#{@lb_applications.inspect}'), 'lb_options' => #{@lb_options.inspect}").formats(@block_format) do
pending if Fog.mocking?
data = Bluebox[:compute].create_block(@product_id, @template_id, 'password' => @password, 'lb_applications' => @lb_applications, 'lb_options' => @lb_options).body
@lb_block_id = data['id']
data
end


unless Fog.mocking?
Bluebox[:compute].servers.get(@block_id).wait_for { ready? }
end
Expand Down Expand Up @@ -56,6 +69,11 @@
Bluebox[:compute].destroy_block(@block_id).body
end

tests("destroy_block('#{@lb_block_id})'").formats({'text' => String}) do
pending if Fog.mocking?
Bluebox[:compute].destroy_block(@block_id).body
end

end

tests('failure') do
Expand Down

0 comments on commit d01faf7

Please sign in to comment.