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:
parent
a5907a9fdc
commit
93ea9de278
5 changed files with 12 additions and 10 deletions
|
@ -22,7 +22,7 @@ module Fog
|
||||||
attribute :template
|
attribute :template
|
||||||
|
|
||||||
# Not reported by the API, but used at create time
|
# Not reported by the API, but used at create time
|
||||||
attr_accessor :name, :password, :ssh_key
|
attr_accessor :password, :ssh_key, :user
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
requires :id
|
requires :id
|
||||||
|
@ -59,7 +59,10 @@ module Fog
|
||||||
elsif @password
|
elsif @password
|
||||||
{'password' => @password}
|
{'password' => @password}
|
||||||
end
|
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)
|
merge_attributes(data.body)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,19 +7,18 @@ module Fog
|
||||||
# ==== Parameters
|
# ==== Parameters
|
||||||
# * product_id<~Integer> - Id of product to create block with
|
# * product_id<~Integer> - Id of product to create block with
|
||||||
# * template_id<~Integer> - Id of template to create block with
|
# * template_id<~Integer> - Id of template to create block with
|
||||||
# * name<~String> - Name of block
|
|
||||||
# * options<~Hash>:
|
# * options<~Hash>:
|
||||||
# * password<~String> - Password for block
|
# * password<~String> - Password for block
|
||||||
# or
|
# or
|
||||||
# * ssh_key<~String> - ssh public key
|
# * ssh_key<~String> - ssh public key
|
||||||
|
# * username<~String> - optional, defaults to deploy
|
||||||
#
|
#
|
||||||
# ==== Returns
|
# ==== Returns
|
||||||
# * response<~Excon::Response>:
|
# * response<~Excon::Response>:
|
||||||
# * body<~Hash>:
|
# * body<~Hash>:
|
||||||
# TODO
|
# TODO
|
||||||
def create_block(product_id, template_id, name, options = {})
|
def create_block(product_id, template_id, options = {})
|
||||||
data = {
|
data = {
|
||||||
'name' => name,
|
|
||||||
'product' => product_id,
|
'product' => product_id,
|
||||||
'template' => template_id
|
'template' => template_id
|
||||||
}.merge!(options)
|
}.merge!(options)
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe 'Fog::Bluebox::Server' do
|
||||||
subject {
|
subject {
|
||||||
@flavor_id = '94fd37a7-2606-47f7-84d5-9000deda52ae' # Block 1GB Virtual Server
|
@flavor_id = '94fd37a7-2606-47f7-84d5-9000deda52ae' # Block 1GB Virtual Server
|
||||||
@image_id = 'a00baa8f-b5d0-4815-8238-b471c4c4bf72' # Ubuntu 9.10 64bit
|
@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
|
before(:each) do
|
||||||
|
|
|
@ -9,7 +9,7 @@ describe 'Fog::Bluebox::Servers' do
|
||||||
subject {
|
subject {
|
||||||
@flavor_id = '94fd37a7-2606-47f7-84d5-9000deda52ae' # Block 1GB Virtual Server
|
@flavor_id = '94fd37a7-2606-47f7-84d5-9000deda52ae' # Block 1GB Virtual Server
|
||||||
@image_id = 'a00baa8f-b5d0-4815-8238-b471c4c4bf72' # Ubuntu 9.10 64bit
|
@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
|
@server
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,12 @@ Shindo.tests('Bluebox | block requests', ['bluebox']) do
|
||||||
|
|
||||||
@product_id = '94fd37a7-2606-47f7-84d5-9000deda52ae' # 1 GB
|
@product_id = '94fd37a7-2606-47f7-84d5-9000deda52ae' # 1 GB
|
||||||
@template_id = 'a00baa8f-b5d0-4815-8238-b471c4c4bf72' # Ubuntu 9.10 64bit
|
@template_id = 'a00baa8f-b5d0-4815-8238-b471c4c4bf72' # Ubuntu 9.10 64bit
|
||||||
@password = 'R8p6ikXOfCxoKy'
|
@password = 'chunkybacon'
|
||||||
|
|
||||||
@block_id = nil
|
@block_id = nil
|
||||||
|
|
||||||
tests("create_block('#{@product_id}', '#{@template_id}', 'fog_block', 'password' => '#{@password}')").formats(@block_format) do
|
tests("create_block('#{@product_id}', '#{@template_id}', 'password' => '#{@password}')").formats(@block_format) do
|
||||||
data = Bluebox[:blocks].create_block(@product_id, @template_id, 'fog_block', 'password' => @password).body
|
data = Bluebox[:blocks].create_block(@product_id, @template_id, 'password' => @password).body
|
||||||
@block_id = data['id']
|
@block_id = data['id']
|
||||||
data
|
data
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue