Skip to content

Commit

Permalink
[bbg] create_block: allow specifying username, remove name param
Browse files Browse the repository at this point in the history
  • Loading branch information
geemus committed Jun 4, 2010
1 parent a5907a9 commit 93ea9de
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
7 changes: 5 additions & 2 deletions lib/fog/bluebox/models/server.rb
Expand Up @@ -22,7 +22,7 @@ class Server < Fog::Model
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
Expand Down Expand Up @@ -59,7 +59,10 @@ def save
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
Expand Down
5 changes: 2 additions & 3 deletions lib/fog/bluebox/requests/create_block.rb
Expand Up @@ -7,19 +7,18 @@ class Real
# ==== 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)
Expand Down
2 changes: 1 addition & 1 deletion spec/bluebox/models/server_spec.rb
Expand Up @@ -8,7 +8,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion spec/bluebox/models/servers_spec.rb
Expand Up @@ -9,7 +9,7 @@
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
}

Expand Down
6 changes: 3 additions & 3 deletions tests/bluebox/requests/block_tests.rb
Expand Up @@ -17,12 +17,12 @@

@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
Expand Down

0 comments on commit 93ea9de

Please sign in to comment.